[PATCH 2/4] Mark IFN_COMPLEX_MUL as commutative

Richard Sandiford richard.sandiford@arm.com
Wed Nov 10 12:49:00 GMT 2021


Mark IFN_COMPLEX_MUL as commutative.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Richard


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                                |  1 +
 .../gcc.target/aarch64/sve/complex_mul_1.c       | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/complex_mul_1.c

diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index 7b13db6dfe3..ff7d43f1801 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -3829,6 +3829,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
index 00000000000..d197e7d0d8e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/complex_mul_1.c
@@ -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" } } */
-- 
2.25.1



More information about the Gcc-patches mailing list