public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/106995 - if-conversion and vanishing loops
@ 2022-11-29 11:59 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-11-29 11:59 UTC (permalink / raw)
  To: gcc-patches

When we version loops for vectorization during if-conversion it
can happen that either loop vanishes because we run some VN and
CFG cleanup.  If the to-be vectorized part vanishes we already
redirect the versioning condition to the original loop.  The following
does the same in case the original loop vanishes as happened
for the testcase in the bug in the past (but no longer).

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR tree-optimization/106995
	* tree-if-conv.cc (pass_if_conversion::execute): Also redirect the
	versioning condition to the original loop if this very loop
	vanished during CFG cleanup.
---
 gcc/tree-if-conv.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc
index 34bb507ff3b..64b20b4a9e1 100644
--- a/gcc/tree-if-conv.cc
+++ b/gcc/tree-if-conv.cc
@@ -3761,7 +3761,8 @@ pass_if_conversion::execute (function *fun)
       if (!gimple_bb (g))
 	continue;
       unsigned ifcvt_loop = tree_to_uhwi (gimple_call_arg (g, 0));
-      if (!get_loop (fun, ifcvt_loop))
+      unsigned orig_loop = tree_to_uhwi (gimple_call_arg (g, 1));
+      if (!get_loop (fun, ifcvt_loop) || !get_loop (fun, orig_loop))
 	{
 	  if (dump_file)
 	    fprintf (dump_file, "If-converted loop vanished\n");
-- 
2.35.3

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

only message in thread, other threads:[~2022-11-29 11:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 11:59 [PATCH] tree-optimization/106995 - if-conversion and vanishing loops 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).