From patchwork Mon Jul 30 11:38:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 950843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-482629-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="HWmKUYOA"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fHf81mgyz9rxx for ; Mon, 30 Jul 2018 21:39:11 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=jIFVboWcigcNPBsZ7otONkUBbzMW+ 5s0NmAviQBXaWBMPEgzcnfaMUNEajskMeCH/eG/bQe2g94PMS+Sxpb8QGgyn5Jfh DNL8HbJd1kclTe1NvYi+Vg5Yps1LNUO4y4ZPnliihsUHia3rVfAdfRFSH7988Ia5 xXMb/vTZ81p8/M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=JutoVqxrd7XGIgRj9c6Bx20ADPo=; b=HWm KUYOAABQ+vRKWi3go3pBv8NFUik3KBZfXng0BF4IEkCkmhgsn4IL+/NBBx00e+3q /d2Mmnq+0I56c+BUXMni8I8/SjufVvcIqEZhBWp9L2t9qgS7a+uPZnofr3Vxax1H LyWSQr9JMGJAaxmw7yjFU/YSaCl/8v96qQHcOWaQ= Received: (qmail 114844 invoked by alias); 30 Jul 2018 11:39:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 114449 invoked by uid 89); 30 Jul 2018 11:39:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: foss.arm.com Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Jul 2018 11:39:03 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D305AED1 for ; Mon, 30 Jul 2018 04:39:01 -0700 (PDT) Received: from localhost (unknown [10.32.98.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5B7923F802 for ; Mon, 30 Jul 2018 04:39:01 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [05/11] Add a vect_stmt_to_vectorize helper function References: <874lghez1a.fsf@arm.com> Date: Mon, 30 Jul 2018 12:38:59 +0100 In-Reply-To: <874lghez1a.fsf@arm.com> (Richard Sandiford's message of "Mon, 30 Jul 2018 12:36:01 +0100") Message-ID: <87in4xdkbw.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 This patch adds a helper that does the opposite of vect_orig_stmt: go from the original scalar statement to the statement that should actually be vectorised. The use in the last two hunks of vectorizable_reduction are because reduc_stmt_info (first hunk) and stmt_info (second hunk) are already pattern statements if appropriate. 2018-07-30 Richard Sandiford gcc/ * tree-vectorizer.h (vect_stmt_to_vectorize): New function. * tree-vect-loop.c (vect_update_vf_for_slp): Use it. (vectorizable_reduction): Likewise. * tree-vect-slp.c (vect_analyze_slp_instance): Likewise. (vect_detect_hybrid_slp_stmts): Likewise. * tree-vect-stmts.c (vect_is_simple_use): Likewise. Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h 2018-07-30 12:32:26.218536339 +0100 +++ gcc/tree-vectorizer.h 2018-07-30 12:32:29.586506669 +0100 @@ -1131,6 +1131,17 @@ vect_orig_stmt (stmt_vec_info stmt_info) return stmt_info; } +/* If STMT_INFO has been replaced by a pattern statement, return the + replacement statement, otherwise return STMT_INFO itself. */ + +inline stmt_vec_info +vect_stmt_to_vectorize (stmt_vec_info stmt_info) +{ + if (STMT_VINFO_IN_PATTERN_P (stmt_info)) + return STMT_VINFO_RELATED_STMT (stmt_info); + return stmt_info; +} + /* Return true if BB is a loop header. */ static inline bool Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-07-30 12:32:26.214536374 +0100 +++ gcc/tree-vect-loop.c 2018-07-30 12:32:29.586506669 +0100 @@ -1424,9 +1424,7 @@ vect_update_vf_for_slp (loop_vec_info lo gsi_next (&si)) { stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (gsi_stmt (si)); - if (STMT_VINFO_IN_PATTERN_P (stmt_info) - && STMT_VINFO_RELATED_STMT (stmt_info)) - stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); + stmt_info = vect_stmt_to_vectorize (stmt_info); if ((STMT_VINFO_RELEVANT_P (stmt_info) || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info))) && !PURE_SLP_STMT (stmt_info)) @@ -6111,8 +6109,7 @@ vectorizable_reduction (stmt_vec_info st return true; stmt_vec_info reduc_stmt_info = STMT_VINFO_REDUC_DEF (stmt_info); - if (STMT_VINFO_IN_PATTERN_P (reduc_stmt_info)) - reduc_stmt_info = STMT_VINFO_RELATED_STMT (reduc_stmt_info); + reduc_stmt_info = vect_stmt_to_vectorize (reduc_stmt_info); if (STMT_VINFO_VEC_REDUCTION_TYPE (reduc_stmt_info) == EXTRACT_LAST_REDUCTION) @@ -6145,8 +6142,7 @@ vectorizable_reduction (stmt_vec_info st if (ncopies > 1 && STMT_VINFO_RELEVANT (reduc_stmt_info) <= vect_used_only_live && (use_stmt_info = loop_vinfo->lookup_single_use (phi_result)) - && (use_stmt_info == reduc_stmt_info - || STMT_VINFO_RELATED_STMT (use_stmt_info) == reduc_stmt_info)) + && vect_stmt_to_vectorize (use_stmt_info) == reduc_stmt_info) single_defuse_cycle = true; /* Create the destination vector */ @@ -6915,8 +6911,7 @@ vectorizable_reduction (stmt_vec_info st if (ncopies > 1 && (STMT_VINFO_RELEVANT (stmt_info) <= vect_used_only_live) && (use_stmt_info = loop_vinfo->lookup_single_use (reduc_phi_result)) - && (use_stmt_info == stmt_info - || STMT_VINFO_RELATED_STMT (use_stmt_info) == stmt_info)) + && vect_stmt_to_vectorize (use_stmt_info) == stmt_info) { single_defuse_cycle = true; epilog_copies = 1; Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2018-07-30 12:32:26.218536339 +0100 +++ gcc/tree-vect-slp.c 2018-07-30 12:32:29.586506669 +0100 @@ -1969,11 +1969,7 @@ vect_analyze_slp_instance (vec_info *vin /* Collect the stores and store them in SLP_TREE_SCALAR_STMTS. */ while (next_info) { - if (STMT_VINFO_IN_PATTERN_P (next_info) - && STMT_VINFO_RELATED_STMT (next_info)) - scalar_stmts.safe_push (STMT_VINFO_RELATED_STMT (next_info)); - else - scalar_stmts.safe_push (next_info); + scalar_stmts.safe_push (vect_stmt_to_vectorize (next_info)); next_info = DR_GROUP_NEXT_ELEMENT (next_info); } } @@ -1983,11 +1979,7 @@ vect_analyze_slp_instance (vec_info *vin SLP_TREE_SCALAR_STMTS. */ while (next_info) { - if (STMT_VINFO_IN_PATTERN_P (next_info) - && STMT_VINFO_RELATED_STMT (next_info)) - scalar_stmts.safe_push (STMT_VINFO_RELATED_STMT (next_info)); - else - scalar_stmts.safe_push (next_info); + scalar_stmts.safe_push (vect_stmt_to_vectorize (next_info)); next_info = REDUC_GROUP_NEXT_ELEMENT (next_info); } /* Mark the first element of the reduction chain as reduction to properly @@ -2325,9 +2317,7 @@ vect_detect_hybrid_slp_stmts (slp_tree n use_vinfo = loop_vinfo->lookup_stmt (use_stmt); if (!use_vinfo) continue; - if (STMT_VINFO_IN_PATTERN_P (use_vinfo) - && STMT_VINFO_RELATED_STMT (use_vinfo)) - use_vinfo = STMT_VINFO_RELATED_STMT (use_vinfo); + use_vinfo = vect_stmt_to_vectorize (use_vinfo); if (!STMT_SLP_TYPE (use_vinfo) && (STMT_VINFO_RELEVANT (use_vinfo) || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (use_vinfo))) Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2018-07-30 12:32:26.218536339 +0100 +++ gcc/tree-vect-stmts.c 2018-07-30 12:32:29.586506669 +0100 @@ -10031,11 +10031,8 @@ vect_is_simple_use (tree operand, vec_in *dt = vect_external_def; else { - if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo)) - { - stmt_vinfo = STMT_VINFO_RELATED_STMT (stmt_vinfo); - def_stmt = stmt_vinfo->stmt; - } + stmt_vinfo = vect_stmt_to_vectorize (stmt_vinfo); + def_stmt = stmt_vinfo->stmt; switch (gimple_code (def_stmt)) { case GIMPLE_PHI: