diff mbox series

tree-optimization/99746 - avoid confusing hybrid code

Message ID nycvar.YFH.7.76.2103251003540.12700@elmra.sevgm.obk
State New
Headers show
Series tree-optimization/99746 - avoid confusing hybrid code | expand

Commit Message

Richard Biener March 25, 2021, 9:04 a.m. UTC
This avoids confusing the hybrid vectorization code with SLP
patterns by not marking SLP pattern covered stmts as patterns
(they are marked as SLP patterns already).  This means that loop
vectorization will vectorize the scalar stmt rather than the SLP
pattern stmt (which it can't anyway).

Bootstrapped and tested on x86_64-unknown-linux-gnu, also tested on
aarch64 by Tamar, pushed.

2021-03-24  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/99746
	* tree-vect-slp-patterns.c (complex_pattern::build): Do not mark
	the scalar stmt as patterned.  Instead set up required things
	manually.

	* gfortran.dg/vect/pr99746.f90: New testcase.
---
 gcc/testsuite/gfortran.dg/vect/pr99746.f90 | 45 ++++++++++++++++++++++
 gcc/tree-vect-slp-patterns.c               | 10 +----
 2 files changed, 47 insertions(+), 8 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/vect/pr99746.f90
diff mbox series

Patch

diff --git a/gcc/testsuite/gfortran.dg/vect/pr99746.f90 b/gcc/testsuite/gfortran.dg/vect/pr99746.f90
new file mode 100644
index 00000000000..fe947ae7ccf
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/vect/pr99746.f90
@@ -0,0 +1,45 @@ 
+! { dg-do compile }
+! { dg-additional-options "-march=armv8.3-a" { target aarch64-*-* } }
+SUBROUTINE CLAREF(A, WANTZ, Z, ICOL1, ITMP1, ITMP2, T1, T2, V2)
+LOGICAL            BLOCK, WANTZ
+COMPLEX            T1, T2, V2
+COMPLEX            A(LDA, *), VECS, Z(LDA, *)
+COMPLEX            SUM
+LOGICAL            LSAME
+IF (LSAME) THEN
+      DO 30 K = ITMP1, ITMP2, 3
+         T1 = VECS0
+30       CONTINUE
+ELSE
+   IF (BLOCK) THEN
+      DO 90 K = ITMP1, ITMP2 - 1, 3
+         A(J, ICOL1) = ITMP1
+         IF (WANTZ) THEN
+            DO 80 J = ITMP1, ITMP2
+               SUM =  ICOL1
+               Z(J, 3) = V23
+80             CONTINUE
+         END IF
+90       CONTINUE
+      DO 120 K = ITMP1, ITMP2
+         V2 = VECS()
+         DO 100 J = ITMP1, ITMP2
+            A(J, ICOL1) = A(J, ICOL1) - SUM
+100          CONTINUE
+         IF (WANTZ) THEN
+            DO 110 J = 1, 3
+               SUM = Z(J, ICOL1)
+               Z(J, ICOL1) = 0
+110             CONTINUE
+         END IF
+         ICOL1 = ICOL1 + 1
+120       CONTINUE
+   ELSE
+      DO 130 J = ITMP1, ITMP2
+         SUM = T1 * A(J, ICOL1) + T2 * A(J, 1) + V2 * A(J, 2)
+         A(J, ICOL1) = SUM
+         A(J, ICOL1 + 2) = SUM * V1
+130       CONTINUE
+   END IF
+END IF
+END
diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c
index 85f2d03754d..cdd61e9a5cf 100644
--- a/gcc/tree-vect-slp-patterns.c
+++ b/gcc/tree-vect-slp-patterns.c
@@ -571,14 +571,8 @@  complex_pattern::build (vec_info *vinfo)
       STMT_VINFO_RELEVANT (call_stmt_info) = vect_used_in_scope;
       STMT_SLP_TYPE (call_stmt_info) = pure_slp;
 
-      /* add_pattern_stmt can't be done in vect_mark_pattern_stmts because
-	 the non-SLP pattern matchers already have added the statement to VINFO
-	 by the time it is called.  Some of them need to modify the returned
-	 stmt_info.  vect_mark_pattern_stmts is called by recog_pattern and it
-	 would increase the size of each pattern with boilerplate code to make
-	 the call there.  */
-      vect_mark_pattern_stmts (vinfo, stmt_info, call_stmt,
-			       SLP_TREE_VECTYPE (node));
+      gimple_set_bb (call_stmt, gimple_bb (stmt_info->stmt));
+      STMT_VINFO_VECTYPE (call_stmt_info) = SLP_TREE_VECTYPE (node);
       STMT_VINFO_SLP_VECT_ONLY_PATTERN (call_stmt_info) = true;
 
       /* Since we are replacing all the statements in the group with the same