Mark IFN_COMPLEX_MUL as commutative
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 30 Nov 2021 09:52:26 +0000 (09:52 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 30 Nov 2021 09:52:26 +0000 (09:52 +0000)
gcc/
* internal-fn.c (commutative_binary_fn_p): Handle IFN_COMPLEX_MUL.

gcc/testsuite/
* gcc.target/aarch64/sve/complex_mul_1.c: New test.

gcc/internal-fn.c
gcc/testsuite/gcc.target/aarch64/sve/complex_mul_1.c [new file with mode: 0644]

index 514ce89..3d4055d 100644 (file)
@@ -3831,6 +3831,7 @@ commutative_binary_fn_p (internal_fn fn)
     case IFN_MULHRS:
     case IFN_FMIN:
     case IFN_FMAX:
+    case IFN_COMPLEX_MUL:
       return true;
 
     default:
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/complex_mul_1.c b/gcc/testsuite/gcc.target/aarch64/sve/complex_mul_1.c
new file mode 100644 (file)
index 0000000..d197e7d
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-options "-O2 -fgimple -fdump-tree-optimized" } */
+
+void __GIMPLE
+foo (__SVFloat64_t x, __SVFloat64_t y, __SVFloat64_t *res1,
+     __SVFloat64_t *res2)
+{
+  __SVFloat64_t a1;
+  __SVFloat64_t a2;
+
+  a1 = .COMPLEX_MUL (x, y);
+  a2 = .COMPLEX_MUL (y, x);
+  __MEM<__SVFloat64_t> (res1) = a1;
+  __MEM<__SVFloat64_t> (res2) = a2;
+}
+
+/* { dg-final { scan-tree-dump-times {\.COMPLEX_MUL} 1 "optimized" } } */