]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/61518 (wrong code (by tree vectorizer) at -O3 on x86_64-linux...
authorYuri Rumyantsev <ysrumyan@gmail.com>
Wed, 18 Jun 2014 11:40:59 +0000 (11:40 +0000)
committerKirill Yukhin <kyukhin@gcc.gnu.org>
Wed, 18 Jun 2014 11:40:59 +0000 (11:40 +0000)
        PR tree-optimization/61518
gcc/
        * tree-if-conv.c (is_cond_scalar_reduction): Add missed check that
        reduction var is used in reduction stmt or phi-function only.

gcc/testsuite/
        * gcc.dg/torture/pr61518.c: New test.

From-SVN: r211780

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr61518.c [new file with mode: 0644]
gcc/tree-if-conv.c

index 2d0a07cda65937e2b14a99f34f80e0dbb8a873d3..19f33b2041c67dc1911331113c11efdf8d2c757c 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-18  Yuri Rumyantsev  <ysrumyan@gmail.com>
+
+       PR tree-optimization/61518
+       * tree-if-conv.c (is_cond_scalar_reduction): Add missed check that
+       reduction var is used in reduction stmt or phi-function only.
+
 2014-06-18  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/arm/arm_neon.h (vadd_f32): Change #ifdef to __FAST_MATH.
index c67305601e6b6501ca8527a98072d985aa33af2e..702fc36af5cf592bab98e637db7608f8b46d3ad4 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-18  Yuri Rumyantsev  <ysrumyan@gmail.com>
+
+       PR tree-optimization/61518
+       * gcc.dg/torture/pr61518.c: New test.
+
 2014-06-18  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        PR tree-optimization/61517
diff --git a/gcc/testsuite/gcc.dg/torture/pr61518.c b/gcc/testsuite/gcc.dg/torture/pr61518.c
new file mode 100644 (file)
index 0000000..98429b0
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+int a, b, c[1], d, e, f;
+
+void
+fn1 ()
+{
+  for (; d < 1; d++)
+    {
+      if (b)
+       {
+         a = e++ && f;
+         b = f;
+       }
+      c[b] = 0;
+    }
+}
+
+int
+main ()
+{
+  fn1 ();
+
+  if (e != 0)
+    __builtin_abort ();
+
+  return 0;
+}
+
index 6e298d328aa6dad2dfb15d3a5a1e4ce625f8a1e8..36a879d1e7bb14d8b209ad20a63962347468c06d 100644 (file)
@@ -1409,6 +1409,8 @@ is_cond_scalar_reduction (gimple phi, gimple *reduc,
   enum tree_code reduction_op;
   struct loop *loop = gimple_bb (phi)->loop_father;
   edge latch_e = loop_latch_edge (loop);
+  imm_use_iterator imm_iter;
+  use_operand_p use_p;
 
   arg_0 = PHI_ARG_DEF (phi, 0);
   arg_1 = PHI_ARG_DEF (phi, 1);
@@ -1465,6 +1467,18 @@ is_cond_scalar_reduction (gimple phi, gimple *reduc,
   else if (r_op1 != PHI_RESULT (header_phi))
     return false;
 
+  /* Check that R_OP1 is used in reduction stmt or in PHI only.  */
+  FOR_EACH_IMM_USE_FAST (use_p, imm_iter, r_op1)
+    {
+      gimple use_stmt = USE_STMT (use_p);
+      if (is_gimple_debug (use_stmt))
+       continue;
+      if (use_stmt == stmt)
+       continue;
+      if (gimple_code (use_stmt) != GIMPLE_PHI)
+       return false;
+    }
+
   *op0 = r_op1; *op1 = r_op2;
   *reduc = stmt;
   return true;