]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/121126 - properly verify live LC PHIs
authorRichard Biener <rguenther@suse.de>
Fri, 18 Jul 2025 06:28:59 +0000 (08:28 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 18 Jul 2025 10:13:20 +0000 (12:13 +0200)
The following makes sure we analyze live LC PHIs not part of
a double reduction.

PR tree-optimization/121126
* tree-vect-stmts.cc (vect_analyze_stmt): Analyze the
live lane extract for LC PHIs that are vect_internal_def.

* gcc.dg/vect/pr121126.c: New testcase.

gcc/testsuite/gcc.dg/vect/pr121126.c [new file with mode: 0644]
gcc/tree-vect-stmts.cc

diff --git a/gcc/testsuite/gcc.dg/vect/pr121126.c b/gcc/testsuite/gcc.dg/vect/pr121126.c
new file mode 100644 (file)
index 0000000..ae6603b
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-additional-options "--param vect-partial-vector-usage=2" } */
+
+#include "tree-vect.h"
+
+unsigned char a;
+unsigned b;
+int r[11];
+static void __attribute__((noipa))
+c(int e, unsigned s[][11][11])
+{
+  for (int u = -(e ? 2000424973 : 0) - 2294542319; u < 7; u += 4)
+    for (int x = 0; x < 300000011; x += 4)
+      for (int y = 0; y < (0 < s[u][4][1]) + 11; y += 3) {
+        a = a ?: 1;
+        b = r[2];
+      }
+}
+long long ab;
+int e = 1;
+unsigned s[11][11][11];
+int main()
+{
+  check_vect ();
+  for (int t = 0; t < 11; ++t)
+    r[t] = 308100;
+  c(e,s);
+  ab = b;
+  if (ab != 308100)
+    __builtin_abort ();
+}
index f0d31058372365225b91644074143faefdce2064..2e9b3d2e68635fcb523887b92aac4bf32cd84390 100644 (file)
@@ -13378,7 +13378,8 @@ vect_analyze_stmt (vec_info *vinfo,
       need extra handling, except for vectorizable reductions.  */
   if (!bb_vinfo
       && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type
-      && STMT_VINFO_TYPE (stmt_info) != lc_phi_info_type
+      && (STMT_VINFO_TYPE (stmt_info) != lc_phi_info_type
+         || STMT_VINFO_DEF_TYPE (stmt_info) == vect_internal_def)
       && (!node->ldst_lanes || SLP_TREE_CODE (node) == VEC_PERM_EXPR)
       && !can_vectorize_live_stmts (as_a <loop_vec_info> (vinfo),
                                    node, node_instance,