Fix PR91145
diff mbox series

Message ID alpine.LSU.2.20.1907121439300.2976@zhemvz.fhfr.qr
State New
Headers show
Series
  • Fix PR91145
Related show

Commit Message

Richard Biener July 12, 2019, 12:40 p.m. UTC
The following fixes the PR.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2019-07-12  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/91145
	* tree-vect-slp.c (vect_build_slp_tree_2): Fix reduction
	chain check.

	* gcc.dg/torture/pr91145.c: New testcase.

Patch
diff mbox series

Index: gcc/testsuite/gcc.dg/torture/pr91145.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr91145.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr91145.c	(working copy)
@@ -0,0 +1,16 @@ 
+/* { dg-do compile } */
+/* { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } } */
+
+int a, c;
+unsigned b, e;
+extern unsigned d[100];
+
+void f()
+{
+  for (int g = 0; g < 70; g++)
+    {
+
+      b += d[g] - c;
+      e -= g ^ a;
+    }
+}
Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c	(revision 273433)
+++ gcc/tree-vect-slp.c	(working copy)
@@ -1140,7 +1140,8 @@  vect_build_slp_tree_2 (vec_info *vinfo,
 	  FOR_EACH_VEC_ELT (stmts, i, other_info)
 	    {
 	      /* But for reduction chains only check on the first stmt.  */
-	      if (REDUC_GROUP_FIRST_ELEMENT (other_info)
+	      if (!STMT_VINFO_DATA_REF (other_info)
+		  && REDUC_GROUP_FIRST_ELEMENT (other_info)
 		  && REDUC_GROUP_FIRST_ELEMENT (other_info) != stmt_info)
 		continue;
 	      if (STMT_VINFO_DEF_TYPE (other_info) != def_type)