]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/106995 - if-conversion and vanishing loops
authorRichard Biener <rguenther@suse.de>
Tue, 29 Nov 2022 09:41:36 +0000 (10:41 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 29 Nov 2022 11:59:23 +0000 (12:59 +0100)
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).

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

index 34bb507ff3ba6a1b97a465d5f1a11ca5b4f90658..64b20b4a9e11fe53d7a4bd188c514fdf759b3f3b 100644 (file)
@@ -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");