From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1130) id 9C6DB39A484F; Fri, 6 Aug 2021 14:37:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C6DB39A484F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Sandiford To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-8838] aarch64: Restrict issue heuristics to inner vector loop X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 54c0d0dd9a85652003aa2c60e1ad245001e60d8c X-Git-Newrev: 65b5ab4744e7f6e77df544c3796f9dc274737cf6 Message-Id: <20210806143748.9C6DB39A484F@sourceware.org> Date: Fri, 6 Aug 2021 14:37:48 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2021 14:37:48 -0000 https://gcc.gnu.org/g:65b5ab4744e7f6e77df544c3796f9dc274737cf6 commit r11-8838-g65b5ab4744e7f6e77df544c3796f9dc274737cf6 Author: Richard Sandiford Date: Fri Aug 6 15:36:57 2021 +0100 aarch64: Restrict issue heuristics to inner vector loop The AArch64 vector costs try to take issue rates into account. However, when vectorising an outer loop, we lumped the inner and outer operations together, which is somewhat meaningless. This patch restricts the heuristic to the inner loop. gcc/ * config/aarch64/aarch64.c (aarch64_add_stmt_cost): Only record issue information for operations that occur in the innermost loop. (cherry picked from commit 9690309baf8294b0512b55b133bc102dc0dac5b5) Diff: --- gcc/config/aarch64/aarch64.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index fc9adefbe04..3113b3b3399 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -15394,6 +15394,10 @@ aarch64_add_stmt_cost (class vec_info *vinfo, void *data, int count, fractional_cost stmt_cost = aarch64_builtin_vectorization_cost (kind, vectype, misalign); + bool in_inner_loop_p = (where == vect_body + && stmt_info + && stmt_in_inner_loop_p (vinfo, stmt_info)); + /* Do one-time initialization based on the vinfo. */ loop_vec_info loop_vinfo = dyn_cast (vinfo); bb_vec_info bb_vinfo = dyn_cast (vinfo); @@ -15440,14 +15444,15 @@ aarch64_add_stmt_cost (class vec_info *vinfo, void *data, int count, stmt_cost = aarch64_adjust_stmt_cost (kind, stmt_info, vectype, stmt_cost); - /* If we're recording a nonzero vector loop body cost, also estimate - the operations that would need to be issued by all relevant - implementations of the loop. */ + /* If we're recording a nonzero vector loop body cost for the + innermost loop, also estimate the operations that would need + to be issued by all relevant implementations of the loop. */ auto *issue_info = aarch64_tune_params.vec_costs->issue_info; if (loop_vinfo && issue_info && costs->vec_flags && where == vect_body + && (!LOOP_VINFO_LOOP (loop_vinfo)->inner || in_inner_loop_p) && vectype && stmt_cost != 0) { @@ -15491,8 +15496,7 @@ aarch64_add_stmt_cost (class vec_info *vinfo, void *data, int count, /* Statements in an inner loop relative to the loop being vectorized are weighted more heavily. The value here is arbitrary and could potentially be improved with analysis. */ - if (where == vect_body && stmt_info - && stmt_in_inner_loop_p (vinfo, stmt_info)) + if (in_inner_loop_p) count *= 50; /* FIXME */ retval = (count * stmt_cost).ceil ();