public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-3077] Fix scalar costing issue introduced by PR84512 fix.
Date: Mon, 23 Aug 2021 12:29:07 +0000 (GMT)	[thread overview]
Message-ID: <20210823122907.6D2AA385DC26@sourceware.org> (raw)

https://gcc.gnu.org/g:12dc8ab983db039a570e3798b468498e2230c7d9

commit r12-3077-g12dc8ab983db039a570e3798b468498e2230c7d9
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Aug 23 13:37:41 2021 +0200

    Fix scalar costing issue introduced by PR84512 fix.
    
    This fixes double-scaling of the inner loop scalar cost caused
    by routing the scalar costs through the add_stmt_cost hook and
    using vect_body as the location.  The issue makes almost every
    outer loop vectorization profitable.
    
    2021-08-23  Richard Biener  <rguenther@suse.de>
    
            * tree-vect-loop.c (vect_compute_single_scalar_iteration_cost):
            Properly scale the inner loop cost only once.

Diff:
---
 gcc/tree-vect-loop.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 995d143dbbd..c521b43a47c 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -1284,6 +1284,8 @@ vect_compute_single_scalar_iteration_cost (loop_vec_info loop_vinfo)
 	  else
             kind = scalar_stmt;
 
+	  /* We are using vect_prologue here to avoid scaling twice
+	     by the inner loop factor.  */
 	  record_stmt_cost (&LOOP_VINFO_SCALAR_ITERATION_COST (loop_vinfo),
 			    factor, kind, stmt_info, 0, vect_prologue);
         }
@@ -1297,11 +1299,13 @@ vect_compute_single_scalar_iteration_cost (loop_vec_info loop_vinfo)
 		    j, si)
     (void) add_stmt_cost (loop_vinfo, target_cost_data, si->count,
 			  si->kind, si->stmt_info, si->vectype,
-			  si->misalign, vect_body);
-  unsigned dummy, body_cost = 0;
-  finish_cost (target_cost_data, &dummy, &body_cost, &dummy);
+			  si->misalign, si->where);
+  unsigned prologue_cost = 0, body_cost = 0, epilogue_cost = 0;
+  finish_cost (target_cost_data, &prologue_cost, &body_cost,
+	       &epilogue_cost);
   destroy_cost_data (target_cost_data);
-  LOOP_VINFO_SINGLE_SCALAR_ITERATION_COST (loop_vinfo) = body_cost;
+  LOOP_VINFO_SINGLE_SCALAR_ITERATION_COST (loop_vinfo)
+    = prologue_cost + body_cost + epilogue_cost;
 }


                 reply	other threads:[~2021-08-23 12:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210823122907.6D2AA385DC26@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).