]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/123775 - add missing expand_vec_cond_expr_p to patterns
authorRichard Biener <rguenther@suse.de>
Fri, 23 Jan 2026 08:58:50 +0000 (09:58 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 23 Jan 2026 12:23:14 +0000 (13:23 +0100)
This adds a missing check on supportability of a VEC_COND_EXPR
to a match.pd pattern.  The existing conditions, in particular
known_eq of TYPE_VECTOR_SUBPARTS, is not enough to distinguish
VNx4SImode from V4SImode with -msve-vector-bits=128.

PR middle-end/123775
* match.pd ((view_convert (vec_cond ...))): Make sure the
resulting vec_cond can be expanded.

* gcc.target/aarch64/sve2/pr123775.c: New testcase.

gcc/match.pd
gcc/testsuite/gcc.target/aarch64/sve2/pr123775.c [new file with mode: 0644]

index e0a2399ca65d64ce536c58684f87ae3c62a26674..155658fe2c83abc10bed3e47312c3d5df709c3b7 100644 (file)
@@ -6258,7 +6258,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (if (VECTOR_TYPE_P (type) && VECTOR_TYPE_P (TREE_TYPE (@1))
       && known_eq (TYPE_VECTOR_SUBPARTS (type),
                   TYPE_VECTOR_SUBPARTS (TREE_TYPE (@1)))
-      && tree_nop_conversion_p (TREE_TYPE (type), TREE_TYPE (TREE_TYPE (@1))))
+      && tree_nop_conversion_p (TREE_TYPE (type), TREE_TYPE (TREE_TYPE (@1)))
+      && (expand_vec_cond_expr_p (type, TREE_TYPE (@0))
+         || !expand_vec_cond_expr_p (TREE_TYPE (@1), TREE_TYPE (@0))))
   (vec_cond @0 (view_convert! @1) (view_convert! @2))))
 
 /* Sink binary operation to branches, but only if we can fold it.  */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/pr123775.c b/gcc/testsuite/gcc.target/aarch64/sve2/pr123775.c
new file mode 100644 (file)
index 0000000..ba29204
--- /dev/null
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-additional-options "-O3 -march=armv9-a+sve2 -msve-vector-bits=128 --param aarch64-autovec-preference=sve-only" } */
+
+int main(int argc, char *argv[]) {
+
+    __attribute__((vector_size((4) * sizeof(int)))) int i0;
+    __attribute__((vector_size((4) * sizeof(int)))) int i1;
+    __attribute__((vector_size((4) * sizeof(int)))) int ires;
+    int i;
+
+    i0 = (__attribute__((vector_size((4) * sizeof(int)))) int){(int)argc, 1, 2,
+                                                               10};
+    i1 = (__attribute__((vector_size((4) * sizeof(int)))) int){0, 3, 2,
+                                                               (int)-23};
+    ;
+    do {
+        ires = (i0 > i1);
+        do {
+            int __i;
+            for (__i = 0; __i < 4; __i++) {
+                if ((ires)[__i] != ((i0)[__i] > (i1)[__i] ? -1 : 0)) {
+                    __builtin_printf("%i != (("
+                                     "%i"
+                                     " "
+                                     ">"
+                                     " "
+                                     "%i"
+                                     " ? -1 : 0) ",
+                                     (ires)[__i], (i0)[__i], (i1)[__i]);
+                    __builtin_abort();
+                }
+            }
+        } while (0);
+    } while (0);
+
+    return 0;
+}