slp: reject non-multiple of 2 laned SLP trees (PR99825)
authorTamar Christina <tamar.christina@arm.com>
Tue, 30 Mar 2021 13:16:03 +0000 (14:16 +0100)
committerTamar Christina <tamar.christina@arm.com>
Tue, 30 Mar 2021 13:16:03 +0000 (14:16 +0100)
TWO_OPERANDS allows any order or number of combinations of + and - operations
but the pattern matcher only supports pairs of operations.

This patch has the pattern matcher for complex numbers reject SLP trees where
the lanes are not a multiple of 2.

gcc/ChangeLog:

PR tree-optimization/99825
* tree-vect-slp-patterns.c (vect_check_evenodd_blend):
Reject non-mult 2 lanes.

gcc/testsuite/ChangeLog:

PR tree-optimization/99825
* gfortran.dg/vect/pr99825.f90: New test.

gcc/testsuite/gfortran.dg/vect/pr99825.f90 [new file with mode: 0644]
gcc/tree-vect-slp-patterns.c

diff --git a/gcc/testsuite/gfortran.dg/vect/pr99825.f90 b/gcc/testsuite/gfortran.dg/vect/pr99825.f90
new file mode 100644 (file)
index 0000000..b1423df
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! { dg-additional-options "-march=armv8.3-a -O3" { target { aarch64*-*-* } } }
+
+program main
+  complex, dimension(3, 2) :: a
+  complex, dimension(2, 4) :: b
+  complex, dimension(3, 4) :: c, res1
+
+  data a /0, (-5., -7.), (11., -13.), 0, 0, 0/
+  data b /0, 0, 0, 0, 0, 0, 0, 0/
+  data res1 /0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0/
+
+  c = matmul(a, conjg(b))
+  if (any(res1 /= c)) stop 2
+end program main
index cdd61e9..b25655c 100644 (file)
@@ -332,7 +332,8 @@ static inline bool
 vect_check_evenodd_blend (lane_permutation_t &permutes,
                         unsigned even, unsigned odd)
 {
-  if (permutes.length () == 0)
+  if (permutes.length () == 0
+      || permutes.length () % 2 != 0)
     return false;
 
   unsigned val[2] = {even, odd};