public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Use find_loop_location from unrolling
@ 2023-08-15  8:34 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-08-15  8:34 UTC (permalink / raw)
  To: gcc-patches

The following uses the common find_loop_location as implemented
by the vectorizer to query a loop location also for unrolling.
That results in a more consistent reporting of locations.

Bootstrap / regtest pending on x86_64-unknown-linux-gnu.

	* tree-ssa-loop-ivcanon.cc: Include tree-vectorizer.h
	(canonicalize_loop_induction_variables): Use find_loop_location.
---
 gcc/tree-ssa-loop-ivcanon.cc | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc
index 70b44600650..18046d77677 100644
--- a/gcc/tree-ssa-loop-ivcanon.cc
+++ b/gcc/tree-ssa-loop-ivcanon.cc
@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-cfgcleanup.h"
 #include "builtins.h"
 #include "tree-ssa-sccvn.h"
+#include "tree-vectorizer.h" /* For find_loop_location */
 #include "dbgcnt.h"
 
 /* Specifies types of loops that may be unrolled.  */
@@ -1294,7 +1295,6 @@ canonicalize_loop_induction_variables (class loop *loop,
   tree niter;
   HOST_WIDE_INT maxiter;
   bool modified = false;
-  dump_user_location_t locus;
   class tree_niter_desc niter_desc;
   bool may_be_zero = false;
 
@@ -1308,9 +1308,7 @@ canonicalize_loop_induction_variables (class loop *loop,
       may_be_zero
 	= niter_desc.may_be_zero && !integer_zerop (niter_desc.may_be_zero);
     }
-  if (TREE_CODE (niter) == INTEGER_CST)
-    locus = last_nondebug_stmt (exit->src);
-  else
+  if (TREE_CODE (niter) != INTEGER_CST)
     {
       /* For non-constant niter fold may_be_zero into niter again.  */
       if (may_be_zero)
@@ -1335,9 +1333,6 @@ canonicalize_loop_induction_variables (class loop *loop,
 	      || TREE_CODE (niter) != INTEGER_CST))
 	niter = find_loop_niter_by_eval (loop, &exit);
 
-      if (exit)
-	locus = last_nondebug_stmt (exit->src);
-
       if (TREE_CODE (niter) != INTEGER_CST)
 	exit = NULL;
     }
@@ -1379,6 +1374,7 @@ canonicalize_loop_induction_variables (class loop *loop,
      populates the loop bounds.  */
   modified |= remove_redundant_iv_tests (loop);
 
+  dump_user_location_t locus = find_loop_location (loop);
   if (try_unroll_loop_completely (loop, exit, niter, may_be_zero, ul,
 				  maxiter, locus, allow_peel))
     return true;
-- 
2.35.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-15  8:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15  8:34 [PATCH] Use find_loop_location from unrolling Richard Biener

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).