]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: Handle FMA_CONJ correctly after SLP layout update.
authorTamar Christina <tamar.christina@arm.com>
Fri, 19 Nov 2021 15:12:38 +0000 (15:12 +0000)
committerTamar Christina <tamar.christina@arm.com>
Fri, 19 Nov 2021 15:12:38 +0000 (15:12 +0000)
Apologies, I got dinged by the i386 regressions bot for a test I didn't have in
my tree at the time I made the previous patch.  The bot was telling me that FMA
stopped working after I strengthened the FMA check in the previous patch.

The reason is that the check is slightly early.  The first check can indeed only
exit early when either node isn't a mult.  However we need to delay till we know
if the node is a MUL or FMA before enforcing that both nodes must be a MULT
since the node to inspect is different if the operation is a MUL or FMA.

Also with the update patch for GCC 11 tree layout update to the new GCC 12 one
I had missed that the difference in which node is conjucated is not symmetrical.

So the test for it can just be testing the inverse order.  It was Currently
no detecting when the first node was conjucated instead of the second one.

This also made me wonder why my own test didn't detect this.  It turns out that
the tests, being copied from the _Float16 ones were incorrectly marked as
xfail.  The _Float16 ones are marked as xfail since C doesn't have a conj
operation for _Float16, which means you get extra type-casts in between.

While you could use the GCC _Complex extension here I opted to mark them xfail
since I wanted to include detection over the widenings next year.

Secondly the double tests were being skipped because Adv. SIMD was missing from
targets supporting Complex Double vectorization.

With these changes all other tests run and pass and only XFAIL ones are
correctly the _Float16 ones.  Sorry for missing this before, testing should now
cover all cases.

gcc/ChangeLog:

PR tree-optimization/103311
PR target/103330
* tree-vect-slp-patterns.c (vect_validate_multiplication): Fix CONJ
test to new codegen.
(complex_mul_pattern::matches): Move check downwards.

gcc/testsuite/ChangeLog:

PR tree-optimization/103311
PR target/103330
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-double.c: Fix it.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-double.c: Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-double.c: Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-float.c: Likewise.
* lib/target-supports.exp
(check_effective_target_vect_complex_add_double): Add Adv. SIMD.

gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-double.c
gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-float.c
gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-double.c
gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-float.c
gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-double.c
gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-float.c
gcc/testsuite/lib/target-supports.exp
gcc/tree-vect-slp-patterns.c

index 462063abc3041d466e8b0261252054a46ef48e15..b77c847403df3253648dc4b2f493364fc1cb6959 100644 (file)
@@ -1,10 +1,11 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target vect_complex_add_double } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
+/* { dg-additional-options "-fdump-tree-vect-details" } */
 
 #define TYPE double
 #define N 16
 #include "complex-mla-template.c"
 
-/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "slp1" } } */
-/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "slp1" } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "vect" } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "vect" } } */
index a88adc8184ece3d6d61c66a42233fde0f1721a78..cd68fd190089bc48615e4098a19450c0f374c275 100644 (file)
@@ -1,10 +1,10 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target vect_complex_add_float } */
-/* { dg-additional-options "-fno-tree-loop-vectorize" } */
+/* { dg-additional-options "-fdump-tree-vect-details" } */
 /* { dg-add-options arm_v8_3a_fp16_complex_neon } */
 
 #define TYPE float
 #define N 16
 #include "complex-mla-template.c"
-/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "slp1" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "slp1" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "vect" } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "vect" } } */
index a434fd1f1d3235392a0240b5861c85d39c48d551..9d9839417a2b09fd7715ce554d9d96827ee3f00c 100644 (file)
@@ -1,12 +1,11 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target vect_complex_add_double } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
+/* { dg-additional-options "-fdump-tree-vect-details" } */
 
 #define TYPE double
 #define N 16
 #include "complex-mls-template.c"
 
-/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */
-/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "slp1" } } */
-/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "slp1" } } */
-/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "slp1" } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "vect" } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "vect" } } */
index b7ccbbdb75743182022465243efcb128ef97fd0c..cf540a08acd1a0ffe0b193dd2346a58afc0bfd2a 100644 (file)
@@ -1,11 +1,11 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target vect_complex_add_float } */
-/* { dg-additional-options "-fno-tree-loop-vectorize" } */
+/* { dg-additional-options "-fdump-tree-vect-details" } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
 
 #define TYPE float
 #define N 16
 #include "complex-mls-template.c"
 
-/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "slp1"  { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "slp1"  { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "vect" } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "vect" } } */
index f7e9386334e1b259d43d35f4bc6b79010d020e6a..dcac519cd98c6dd5773117134ca1c007ae3e3856 100644 (file)
@@ -1,10 +1,11 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target vect_complex_add_double } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
+/* { dg-additional-options "-fdump-tree-vect-details" } */
 
 #define TYPE double
 #define N 16
 #include "complex-mul-template.c"
 
-/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "slp1" } } */
-/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" slp1" } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "vect" } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "vect" } } */
index 0dc9c52555640c34f794e0f57c04f3ea0510fdc9..27280ae2ba4dfaee1a547d43f75240a7634caa9b 100644 (file)
@@ -7,5 +7,5 @@
 #define N 16
 #include "complex-mul-template.c"
 
-/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "slp1"  { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "slp1"  { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "slp1" } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "slp1" } } */
index c928d99a14be1192b5f4154a833b9fef5c8cf0e7..155034c9ca4880bf9b46a2ea84fd640754c805c7 100644 (file)
@@ -3632,8 +3632,10 @@ proc check_effective_target_vect_complex_add_float { } {
 proc check_effective_target_vect_complex_add_double { } {
     return [check_cached_effective_target_indexed vect_complex_add_double {
       expr {
-        ([check_effective_target_aarch64_sve2]
-             && [check_effective_target_aarch64_little_endian])
+        (([check_effective_target_arm_v8_3a_complex_neon_ok]
+         && [check_effective_target_aarch64_little_endian])
+        || ([check_effective_target_aarch64_sve2]
+             && [check_effective_target_aarch64_little_endian]))
        }}]
 }
 
index d916fc9cef9a86a0d797caaf2b2f253685e9b7dd..0350441fad9690cd5d04337171ca3470a064a571 100644 (file)
@@ -809,14 +809,20 @@ vect_validate_multiplication (slp_tree_to_load_perm_map_t *perm_cache,
       if (linear_loads_p (perm_cache, left_op[index2]) == PERM_EVENODD)
        return true;
     }
-  else if (kind == PERM_EVENODD)
+  else if (kind == PERM_EVENODD && !neg_first)
     {
-      if ((kind = linear_loads_p (perm_cache, left_op[index2])) == PERM_EVENODD)
+      if ((kind = linear_loads_p (perm_cache, left_op[index2])) != PERM_EVENEVEN)
        return false;
       return true;
     }
-  else if (!neg_first)
-    *conj_first_operand = true;
+  else if (kind == PERM_EVENEVEN && neg_first)
+    {
+      if ((kind = linear_loads_p (perm_cache, left_op[index2])) != PERM_EVENODD)
+       return false;
+
+      *conj_first_operand = true;
+      return true;
+    }
   else
     return false;
 
@@ -949,7 +955,7 @@ complex_mul_pattern::matches (complex_operation_t op,
 
   bool mul0 = vect_match_expression_p (l0node[0], MULT_EXPR);
   bool mul1 = vect_match_expression_p (l0node[1], MULT_EXPR);
-  if (!mul0 || !mul1)
+  if (!mul0 && !mul1)
     return IFN_LAST;
 
   /* Now operand2+4 may lead to another expression.  */
@@ -962,7 +968,7 @@ complex_mul_pattern::matches (complex_operation_t op,
     {
       auto vals = SLP_TREE_CHILDREN (l0node[0]);
       /* Check if it's a multiply, otherwise no idea what this is.  */
-      if (!vect_match_expression_p (vals[1], MULT_EXPR))
+      if (!(mul0 = vect_match_expression_p (vals[1], MULT_EXPR)))
        return IFN_LAST;
 
       /* Check if the ADD is linear, otherwise it's not valid complex FMA.  */
@@ -979,6 +985,8 @@ complex_mul_pattern::matches (complex_operation_t op,
 
   if (left_op.length () != 2
       || right_op.length () != 2
+      || !mul0
+      || !mul1
       || linear_loads_p (perm_cache, left_op[1]) == PERM_ODDEVEN)
     return IFN_LAST;
 
@@ -993,7 +1001,7 @@ complex_mul_pattern::matches (complex_operation_t op,
       if (!vect_validate_multiplication (perm_cache, left_op, PERM_EVENEVEN)
          || vect_normalize_conj_loc (left_op))
        return IFN_LAST;
-      if (!mul0)
+      if (add0)
        ifn = IFN_COMPLEX_FMA;
       else
        ifn = IFN_COMPLEX_MUL;
@@ -1005,7 +1013,7 @@ complex_mul_pattern::matches (complex_operation_t op,
                                         false))
        return IFN_LAST;
 
-      if(!mul0)
+      if(add0)
        ifn = IFN_COMPLEX_FMA_CONJ;
       else
        ifn = IFN_COMPLEX_MUL_CONJ;