Fix PR92161
diff mbox series

Message ID nycvar.YFH.7.76.1910211330360.5566@zhemvz.fhfr.qr
State New
Headers show
Series
  • Fix PR92161
Related show

Commit Message

Richard Biener Oct. 21, 2019, 11:31 a.m. UTC
Bootstrapped & tested on x86_64-unknown-linux-gnu, applied.

Richard.

2019-10-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/92161
	* tree-vect-loop.c (vect_analyze_loop_2): Reset stmts def-type
	for reductions.

	* gfortran.dg/pr92161.f: New testcase.

Patch
diff mbox series

Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	(revision 277237)
+++ gcc/tree-vect-loop.c	(working copy)
@@ -2260,6 +2260,17 @@  again:
 	{
 	  stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (gsi_stmt (si));
 	  STMT_SLP_TYPE (stmt_info) = loop_vect;
+	  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def
+	      || STMT_VINFO_DEF_TYPE (stmt_info) == vect_double_reduction_def)
+	    {
+	      /* vectorizable_reduction adjusts reduction stmt def-types,
+		 restore them to that of the PHI.  */
+	      STMT_VINFO_DEF_TYPE (STMT_VINFO_REDUC_DEF (stmt_info))
+		= STMT_VINFO_DEF_TYPE (stmt_info);
+	      STMT_VINFO_DEF_TYPE (vect_stmt_to_vectorize
+					(STMT_VINFO_REDUC_DEF (stmt_info)))
+		= STMT_VINFO_DEF_TYPE (stmt_info);
+	    }
 	}
       for (gimple_stmt_iterator si = gsi_start_bb (bb);
 	   !gsi_end_p (si); gsi_next (&si))
Index: gcc/testsuite/gfortran.dg/pr92161.f
===================================================================
--- gcc/testsuite/gfortran.dg/pr92161.f	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr92161.f	(working copy)
@@ -0,0 +1,23 @@ 
+! { dg-do compile }
+! { dg-options "-O1 -ftree-loop-vectorize -fno-signed-zeros -fno-trapping-math" }
+! { dg-additional-options "-mvsx" { target { powerpc*-*-* } } }
+      COMPLEX FUNCTION R1 (ZR, CC, EA, U6)
+
+      INTEGER ZR, U6, FZ, J2
+      COMPLEX EA(*), CC
+      DOUBLE PRECISION OS, GA, YU, XT
+
+      OS = DBLE(REAL(CC))
+      GA = DBLE(AIMAG(CC))
+      J2 = 1
+
+      DO 5 FZ = 1, ZR
+        YU = DBLE(REAL(EA(J2)))
+        XT = DBLE(AIMAG(EA(J2)))
+        OS = OS + (YU * 2) - (XT * 2)
+        GA = GA + (YU * 3) + (XT * 3)
+        J2 = J2 + U6
+    5 CONTINUE
+      R1 = CMPLX(REAL(OS), REAL(GA))
+      RETURN
+      END