From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108064 invoked by alias); 30 Jul 2018 11:38:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 108054 invoked by uid 89); 30 Jul 2018 11:38:29 -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=Regular, build_zero_cst 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:38:27 +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 B0D91ED1 for ; Mon, 30 Jul 2018 04:38:26 -0700 (PDT) Received: from localhost (unknown [10.32.98.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 394893F802 for ; Mon, 30 Jul 2018 04:38:26 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [04/11] Add a vect_orig_stmt helper function References: <874lghez1a.fsf@arm.com> Date: Mon, 30 Jul 2018 11:38:00 -0000 In-Reply-To: <874lghez1a.fsf@arm.com> (Richard Sandiford's message of "Mon, 30 Jul 2018 12:36:01 +0100") Message-ID: <87muu9dkcv.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-07/txt/msg01825.txt.bz2 This patch just adds a helper function for going from a potential pattern statement to the original scalar statement. 2018-07-30 Richard Sandiford gcc/ * tree-vectorizer.h (vect_orig_stmt): New function. * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Use it. * tree-vect-loop.c (vect_model_reduction_cost): Likewise. (vect_create_epilog_for_reduction): Likewise. (vectorizable_live_operation): Likewise. * tree-vect-slp.c (vect_find_last_scalar_stmt_in_slp): Likewise. (vect_detect_hybrid_slp_stmts, vect_schedule_slp): Likewise. * tree-vect-stmts.c (vectorizable_call): Likewise. (vectorizable_simd_clone_call, vect_remove_stores): Likewise. Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h 2018-07-30 12:32:22.718567174 +0100 +++ gcc/tree-vectorizer.h 2018-07-30 12:32:26.218536339 +0100 @@ -1120,6 +1120,17 @@ is_pattern_stmt_p (stmt_vec_info stmt_in return stmt_info->pattern_stmt_p; } +/* If STMT_INFO is a pattern statement, return the statement that it + replaces, otherwise return STMT_INFO itself. */ + +inline stmt_vec_info +vect_orig_stmt (stmt_vec_info stmt_info) +{ + if (is_pattern_stmt_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-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c 2018-07-30 12:32:08.934688600 +0100 +++ gcc/tree-vect-data-refs.c 2018-07-30 12:32:26.214536374 +0100 @@ -214,10 +214,8 @@ vect_preserves_scalar_order_p (dr_vec_in (but could happen later) while reads will happen no later than their current position (but could happen earlier). Reordering is therefore only possible if the first access is a write. */ - if (is_pattern_stmt_p (stmtinfo_a)) - stmtinfo_a = STMT_VINFO_RELATED_STMT (stmtinfo_a); - if (is_pattern_stmt_p (stmtinfo_b)) - stmtinfo_b = STMT_VINFO_RELATED_STMT (stmtinfo_b); + stmtinfo_a = vect_orig_stmt (stmtinfo_a); + stmtinfo_b = vect_orig_stmt (stmtinfo_b); stmt_vec_info earlier_stmt_info = get_earlier_stmt (stmtinfo_a, stmtinfo_b); return !DR_IS_WRITE (STMT_VINFO_DATA_REF (earlier_stmt_info)); } Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-07-30 12:32:22.714567210 +0100 +++ gcc/tree-vect-loop.c 2018-07-30 12:32:26.214536374 +0100 @@ -3814,10 +3814,7 @@ vect_model_reduction_cost (stmt_vec_info vectype = STMT_VINFO_VECTYPE (stmt_info); mode = TYPE_MODE (vectype); - stmt_vec_info orig_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); - - if (!orig_stmt_info) - orig_stmt_info = stmt_info; + stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info); code = gimple_assign_rhs_code (orig_stmt_info->stmt); @@ -4738,13 +4735,8 @@ vect_create_epilog_for_reduction (vecstmt); group_size = 1; } @@ -7898,10 +7886,8 @@ vectorizable_live_operation (stmt_vec_in return true; } - /* If stmt has a related stmt, then use that for getting the lhs. */ - gimple *stmt = (is_pattern_stmt_p (stmt_info) - ? STMT_VINFO_RELATED_STMT (stmt_info)->stmt - : stmt_info->stmt); + /* Use the lhs of the original scalar statement. */ + gimple *stmt = vect_orig_stmt (stmt_info)->stmt; lhs = (is_a (stmt)) ? gimple_phi_result (stmt) : gimple_get_lhs (stmt); Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2018-07-30 12:32:22.714567210 +0100 +++ gcc/tree-vect-slp.c 2018-07-30 12:32:26.218536339 +0100 @@ -1848,8 +1848,7 @@ vect_find_last_scalar_stmt_in_slp (slp_t for (int i = 0; SLP_TREE_SCALAR_STMTS (node).iterate (i, &stmt_vinfo); i++) { - if (is_pattern_stmt_p (stmt_vinfo)) - stmt_vinfo = STMT_VINFO_RELATED_STMT (stmt_vinfo); + stmt_vinfo = vect_orig_stmt (stmt_vinfo); last = last ? get_later_stmt (stmt_vinfo, last) : stmt_vinfo; } @@ -2314,10 +2313,7 @@ vect_detect_hybrid_slp_stmts (slp_tree n gcc_checking_assert (PURE_SLP_STMT (stmt_vinfo)); /* If we get a pattern stmt here we have to use the LHS of the original stmt for immediate uses. */ - gimple *stmt = stmt_vinfo->stmt; - if (! STMT_VINFO_IN_PATTERN_P (stmt_vinfo) - && STMT_VINFO_RELATED_STMT (stmt_vinfo)) - stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo)->stmt; + gimple *stmt = vect_orig_stmt (stmt_vinfo)->stmt; tree def; if (gimple_code (stmt) == GIMPLE_PHI) def = gimple_phi_result (stmt); @@ -4087,8 +4083,7 @@ vect_schedule_slp (vec_info *vinfo) if (!STMT_VINFO_DATA_REF (store_info)) break; - if (is_pattern_stmt_p (store_info)) - store_info = STMT_VINFO_RELATED_STMT (store_info); + store_info = vect_orig_stmt (store_info); /* Free the attached stmt_vec_info and remove the stmt. */ vinfo->remove_stmt (store_info); } Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2018-07-30 12:32:22.718567174 +0100 +++ gcc/tree-vect-stmts.c 2018-07-30 12:32:26.218536339 +0100 @@ -3628,8 +3628,7 @@ vectorizable_call (stmt_vec_info stmt_in if (slp_node) return true; - if (is_pattern_stmt_p (stmt_info)) - stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); + stmt_info = vect_orig_stmt (stmt_info); lhs = gimple_get_lhs (stmt_info->stmt); gassign *new_stmt @@ -4364,10 +4363,7 @@ vectorizable_simd_clone_call (stmt_vec_i if (scalar_dest) { type = TREE_TYPE (scalar_dest); - if (is_pattern_stmt_p (stmt_info)) - lhs = gimple_call_lhs (STMT_VINFO_RELATED_STMT (stmt_info)->stmt); - else - lhs = gimple_call_lhs (stmt); + lhs = gimple_call_lhs (vect_orig_stmt (stmt_info)->stmt); new_stmt = gimple_build_assign (lhs, build_zero_cst (type)); } else @@ -9843,8 +9839,7 @@ vect_remove_stores (stmt_vec_info first_ while (next_stmt_info) { stmt_vec_info tmp = DR_GROUP_NEXT_ELEMENT (next_stmt_info); - if (is_pattern_stmt_p (next_stmt_info)) - next_stmt_info = STMT_VINFO_RELATED_STMT (next_stmt_info); + next_stmt_info = vect_orig_stmt (next_stmt_info); /* Free the attached stmt_vec_info and remove the stmt. */ vinfo->remove_stmt (next_stmt_info); next_stmt_info = tmp;