re PR tree-optimization/92161 (ICE in vect_get_vec_def_for_stmt_copy, at tree-vect...
authorRichard Biener <rguenther@suse.de>
Mon, 21 Oct 2019 11:32:25 +0000 (11:32 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 21 Oct 2019 11:32:25 +0000 (11:32 +0000)
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.

From-SVN: r277240

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr92161.f [new file with mode: 0644]
gcc/tree-vect-loop.c

index b274478d1f1ace029173f2959dd735e96e247174..259550ffc410e309540aea6acb46024b66226922 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2019-10-21  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/aarch64/aarch64.md (UNSPEC_RNDR, UNSPEC_RNDRRS): Define.
index 8fd1fd56f24e75828cf1789247e8ad3719810545..d958e642ee08c5b2f47db5d4cd49b1ab5544b1a5 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92161
+       * gfortran.dg/pr92161.f: New testcase.
+
 2019-10-21  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * gcc.target/aarch64/acle/rng_1.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr92161.f b/gcc/testsuite/gfortran.dg/pr92161.f
new file mode 100644 (file)
index 0000000..11f1edf
--- /dev/null
@@ -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
index d073620befb2e3c5d355a74b9f2a7af01f363ee1..a7f19ca4beb367f32ef6d68edbae4ec834dc7158 100644 (file)
@@ -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))