]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/108482 - remove stray .LOOP_DIST_ALIAS calls
authorRichard Biener <rguenther@suse.de>
Mon, 23 Jan 2023 09:22:38 +0000 (10:22 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 23 Jan 2023 10:51:06 +0000 (11:51 +0100)
The following deals with .LOOP_DIST_ALIAS surviving vectorization
because any of the loops involved were elided between loop distribution
and vectorization.  As opposed to .LOOP_VECTORIZED which exists only
between if-conversion and vectorization with no intermediate passes
this is more difficult to deal with in advance and thus cleaning
up after vectorization looks better.  There's the unconditional
vector lowering pass which looks like a good place for this (for
SIMD uid we have pass_simduid_cleanup).

PR tree-optimization/108482
* tree-vect-generic.cc (expand_vector_operations): Fold remaining
.LOOP_DIST_ALIAS calls.

* gcc.dg/torture/pr108482.c: New testcase.

gcc/testsuite/gcc.dg/torture/pr108482.c [new file with mode: 0644]
gcc/tree-vect-generic.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr108482.c b/gcc/testsuite/gcc.dg/torture/pr108482.c
new file mode 100644 (file)
index 0000000..8dc1169
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+int g_30, g_261, g_263, func_1___trans_tmp_17;
+int **g_120;
+int *g_530;
+void func_1() {
+  int *l_29 = &g_30;
+  *l_29 = 1;
+  g_263 = 0;
+  for (; g_263 <= 1; g_263 += 1) {
+    g_530 = 0;
+    if (*l_29) {
+      char *l_1694 = (char *)&g_261;
+      *l_1694 &= **g_120;
+    } else
+      *l_29 ^= func_1___trans_tmp_17;
+  }
+}
index 2e2d7567293dcfc19aaa7ba0344799748e5def6e..166a248f4b9512d4c6fc8d760b458b7a467f7790 100644 (file)
@@ -2398,6 +2398,14 @@ expand_vector_operations (void)
          if (maybe_clean_eh_stmt (gsi_stmt (gsi))
              && gimple_purge_dead_eh_edges (bb))
            cfg_changed = true;
+         /* If a .LOOP_DIST_ALIAS call prevailed loops got elided
+            before vectorization got a chance to get at them.  Simply
+            fold as if loop distribution wasn't performed.  */
+         if (gimple_call_internal_p (gsi_stmt (gsi), IFN_LOOP_DIST_ALIAS))
+           {
+             fold_loop_internal_call (gsi_stmt (gsi), boolean_false_node);
+             cfg_changed = true;
+           }
        }
     }