From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79722 invoked by alias); 1 Aug 2018 12:50:24 -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 77245 invoked by uid 89); 1 Aug 2018 12:50:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Regular, orig_stmt_info, 26.214536374, 26214536374 X-HELO: mail-lj1-f193.google.com Received: from mail-lj1-f193.google.com (HELO mail-lj1-f193.google.com) (209.85.208.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Aug 2018 12:50:17 +0000 Received: by mail-lj1-f193.google.com with SMTP id 203-v6so16733161ljj.13 for ; Wed, 01 Aug 2018 05:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=PSd77xOXE4FwmchDJE0bUGnsFEBxgNZAWmFq9U12k60=; b=YDu/ty4ujdTLaO/iqcbaoyE2dhiOqJuXIn+GVDYI94KxcbFmcpByEzPW4Pq7B2aP7P UHpOSE31qrxMXeZu1Xes3EwfDcU9WxGwR/RokY8RsK/IoCRIsBxJF26mbtlFhDTHCTQM td+y6FvZkjXxhay1zFfpCXvK4Q65fDYJPTtOusc37o5C3jbwF2TNuJtLuXoG5aawEQ8O u9Hdu44hs5PCAn3FZcpMr7LD3cOaUFyqFJamEJCy3VnFJuieAFPGuyExAjdjOB0f5M49 F2Yn3Mn2k9M6r6d3JqmYR8hCB3N84OF638IudZIQ3YJ3HOE/ZtRE8VDyQCDwWkHP3SXH DIRg== MIME-Version: 1.0 References: <874lghez1a.fsf@arm.com> <87muu9dkcv.fsf@arm.com> In-Reply-To: <87muu9dkcv.fsf@arm.com> From: Richard Biener Date: Wed, 01 Aug 2018 12:50:00 -0000 Message-ID: Subject: Re: [04/11] Add a vect_orig_stmt helper function To: GCC Patches , richard.sandiford@arm.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00069.txt.bz2 On Mon, Jul 30, 2018 at 1:38 PM Richard Sandiford wrote: > > This patch just adds a helper function for going from a potential > pattern statement to the original scalar statement. OK. Richard. > > 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 (vec Otherwise (it is a regular reduction) - the tree-code and scalar-def > are taken from STMT. */ > > - stmt_vec_info orig_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); > - if (!orig_stmt_info) > - { > - /* Regular reduction */ > - orig_stmt_info = stmt_info; > - } > - else > + stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info); > + if (orig_stmt_info != stmt_info) > { > /* Reduction pattern */ > gcc_assert (STMT_VINFO_IN_PATTERN_P (orig_stmt_info)); > @@ -5540,11 +5532,7 @@ vect_create_epilog_for_reduction (vec if (REDUC_GROUP_FIRST_ELEMENT (stmt_info)) > { > stmt_vec_info dest_stmt_info > - = SLP_TREE_SCALAR_STMTS (slp_node)[group_size - 1]; > - /* Handle reduction patterns. */ > - if (STMT_VINFO_RELATED_STMT (dest_stmt_info)) > - dest_stmt_info = STMT_VINFO_RELATED_STMT (dest_stmt_info); > - > + = vect_orig_stmt (SLP_TREE_SCALAR_STMTS (slp_node)[group_size - 1]); > scalar_dest = gimple_assign_lhs (dest_stmt_info->stmt); > 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;