]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/118529 - ICE with condition vectorization
authorRichard Biener <rguenther@suse.de>
Fri, 17 Jan 2025 14:41:19 +0000 (15:41 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Sat, 18 Jan 2025 14:28:55 +0000 (15:28 +0100)
On sparc we end up choosing vector(8) <signed-boolean:1> for the
condition but vector(2) int for the value of a COND_EXPR but we
fail to verify their shapes match and thus things go downhill.

This is a missed-optimization on the pattern recognition side
as well as unhandled vector decomposition in vectorizable_condition.
The following plugs just the observed ICE for now.

PR tree-optimization/118529
* tree-vect-stmts.cc (vectorizable_condition): Check the
shape of the vector and condition vector type are compatible.

* gcc.target/sparc/pr118529.c: New testcase.

gcc/testsuite/gcc.target/sparc/pr118529.c [new file with mode: 0644]
gcc/tree-vect-stmts.cc

diff --git a/gcc/testsuite/gcc.target/sparc/pr118529.c b/gcc/testsuite/gcc.target/sparc/pr118529.c
new file mode 100644 (file)
index 0000000..1393763
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -mvis3" } */
+
+long c;
+int d[10];
+int e;
+void g() {
+  int b = 1 & e;
+  int *f = d;
+  b = -b;
+  c = 0;
+  for (; c < 10; c++) {
+    int h = f[c] ^ c;
+    h &= b;
+    f[c] ^= h;
+  }
+}
index b5dd1a2e40f1acc3989bbcec075395b53891b0e7..833029fcb00108abc605042376e9811651d5cd64 100644 (file)
@@ -12676,8 +12676,9 @@ vectorizable_condition (vec_info *vinfo,
 
   masked = !COMPARISON_CLASS_P (cond_expr);
   vec_cmp_type = truth_type_for (comp_vectype);
-
-  if (vec_cmp_type == NULL_TREE)
+  if (vec_cmp_type == NULL_TREE
+      || maybe_ne (TYPE_VECTOR_SUBPARTS (vectype),
+                  TYPE_VECTOR_SUBPARTS (vec_cmp_type)))
     return false;
 
   cond_code = TREE_CODE (cond_expr);