]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: ensure that VEC_PERM operands get lowered to the same SSA_NAME. [PR107717]
authorTamar Christina <tamar.christina@arm.com>
Thu, 17 Nov 2022 08:20:59 +0000 (08:20 +0000)
committerTamar Christina <tamar.christina@arm.com>
Thu, 17 Nov 2022 08:20:59 +0000 (08:20 +0000)
At the moment when the VEC_PERMs generated by this match.pd rule is generated
it creates two different SSA_NAMEs for the folded operand.  Because of this it
the permute switches from a single operand permute to a two operand permute and
the target may no longer support a permute for this.

This fixes it by ensuring we generate the same SSA_NAME for both operands.

gcc/ChangeLog:

PR tree-optimization/107717
* match.pd: Ensure same SSA_NAME.

gcc/testsuite/ChangeLog:

PR tree-optimization/107717
* gcc.target/aarch64/sve2/pr107717.c: New test.

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

index fe1178cf0d5038dbab3e3144937b8b8f4d734fc2..5aba1653b80ef429caf661e60490c28cd1aaaab3 100644 (file)
@@ -8262,7 +8262,7 @@ and,
  (simplify
   (op (vec_perm @0 @0 @2) (vec_perm @1 @1 @2))
    (if (VECTOR_INTEGER_TYPE_P (type))
-    (vec_perm (op @0 @1) (op @0 @1) @2))))
+    (vec_perm (op@3 @0 @1) @3 @2))))
 
 /* Similar for float arithmetic when permutation constant covers
    all vector elements.  */
@@ -8301,4 +8301,4 @@ and,
         }
       }
       (if (full_perm_p)
-       (vec_perm (op @0 @1) (op @0 @1) @2))))))
+       (vec_perm (op@3 @0 @1) @3 @2))))))
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/pr107717.c b/gcc/testsuite/gcc.target/aarch64/sve2/pr107717.c
new file mode 100644 (file)
index 0000000..09dc9af
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3 -march=armv8-a+sve2" } */
+
+void foo(int n, char *restrict out, char *restrict in) {
+  for (int i=n; i-->0; ) {
+    out[i] += in[i];
+  }
+}