From 9c68e2abe294a48385224cd7617eca0720144b5c Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Tue, 30 Mar 2021 14:16:03 +0100 Subject: [PATCH] slp: reject non-multiple of 2 laned SLP trees (PR99825) 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 | 15 +++++++++++++++ gcc/tree-vect-slp-patterns.c | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/vect/pr99825.f90 diff --git a/gcc/testsuite/gfortran.dg/vect/pr99825.f90 b/gcc/testsuite/gfortran.dg/vect/pr99825.f90 new file mode 100644 index 00000000000..b1423df3225 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/pr99825.f90 @@ -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 diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c index cdd61e9a5cf..b25655c9876 100644 --- a/gcc/tree-vect-slp-patterns.c +++ b/gcc/tree-vect-slp-patterns.c @@ -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};