re PR tree-optimization/92252 (ICE: Segmentation fault (in vect_stmt_to_vectorize))
authorRichard Biener <rguenther@suse.de>
Mon, 28 Oct 2019 13:43:49 +0000 (13:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 28 Oct 2019 13:43:49 +0000 (13:43 +0000)
2019-10-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/92252
* tree-vect-slp.c (vect_get_and_check_slp_defs): Adjust
STMT_VINFO_REDUC_IDX when swapping operands.

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

From-SVN: r277517

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr92252.c [new file with mode: 0644]
gcc/tree-vect-slp.c

index 98090400569218f92c0566d8f67d6cc067dc4b5d..c9daad995d7c028c64c58bf35eeec22d6106433f 100644 (file)
@@ -1,3 +1,9 @@
+2019-10-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92252
+       * tree-vect-slp.c (vect_get_and_check_slp_defs): Adjust
+       STMT_VINFO_REDUC_IDX when swapping operands.
+
 2019-10-28  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92241
index 41dea35bdc6723e2f7f75f03d9fffb0c8de7fe8d..5d1ddbe4146519072b67aa6922b35b85b01f9939 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92252
+       * gcc.dg/torture/pr92252.c: New testcase.
+
 2019-10-28  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92241
diff --git a/gcc/testsuite/gcc.dg/torture/pr92252.c b/gcc/testsuite/gcc.dg/torture/pr92252.c
new file mode 100644 (file)
index 0000000..eea60a0
--- /dev/null
@@ -0,0 +1,23 @@
+/* { do-do compile } */
+/* { dg-additional-options "-ftree-vectorize" } */
+
+long int ar;
+int dt;
+
+long int
+pc (unsigned long int q3, int zw)
+{
+  long int em = 0;
+
+  while (zw < 1)
+    {
+      q3 = zw * 2ul;
+      if (q3 != 0)
+        for (ar = 0; ar < 2; ++ar)
+          em = dt;
+
+      ++zw;
+    }
+
+  return em;
+}
index e32731b6db16b06508bee4c373536fd611d07f4d..b75594c36e9388844ee6376b1db811d757e1e966 100644 (file)
@@ -563,6 +563,10 @@ again:
            {
              swap_ssa_operands (stmt, gimple_assign_rhs2_ptr (stmt),
                                 gimple_assign_rhs3_ptr (stmt));
+             if (STMT_VINFO_REDUC_IDX (stmt_info) == 1)
+               STMT_VINFO_REDUC_IDX (stmt_info) = 2;
+             else if (STMT_VINFO_REDUC_IDX (stmt_info) == 2)
+               STMT_VINFO_REDUC_IDX (stmt_info) = 1;
              bool honor_nans = HONOR_NANS (TREE_OPERAND (cond, 0));
              code = invert_tree_comparison (TREE_CODE (cond), honor_nans);
              gcc_assert (code != ERROR_MARK);