]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/61576 (wrong code at -O3 on x86_64-linux-gnu)
authorYuri Rumyantsev <ysrumyan@gmail.com>
Tue, 8 Jul 2014 07:52:12 +0000 (07:52 +0000)
committerKirill Yukhin <kyukhin@gcc.gnu.org>
Tue, 8 Jul 2014 07:52:12 +0000 (07:52 +0000)
PR tree-optimization/61576

gcc/
* tree-if-conv.c (is_cond_scalar_reduction): Add check that
basic block containing reduction statement is predecessor
of phi basi block.

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

From-SVN: r212347

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

index edf3dc11d5e310df392fd3978b0e1b7fb499e9c0..84ed7824c3b9ec18640593526ebc0826e190e245 100644 (file)
@@ -1,3 +1,10 @@
+2014-07-08  Yuri Rumyantsev  <ysrumyan@gmail.com>
+
+       PR tree-optimization/61576
+       * tree-if-conv.c (is_cond_scalar_reduction): Add check that
+       basic block containing reduction statement is predecessor
+       of phi basi block.
+
 2014-07-08  Marek Polacek  <polacek@redhat.com>
 
        PR c/60226
index 9940e724cb309b36d787d99859734d6d1b0a85ea..1350da434d64bae480c7dbb88ebee6c4ff5c536d 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-08  Yuri Rumyantsev  <ysrumyan@gmail.com>
+
+       PR tree-optimization/61576
+       * gcc.dg/torture/pr61576.c: New test.
+
 2014-07-08  Marek Polacek  <polacek@redhat.com>
 
        PR c/60226
diff --git a/gcc/testsuite/gcc.dg/torture/pr61576.c b/gcc/testsuite/gcc.dg/torture/pr61576.c
new file mode 100644 (file)
index 0000000..4ac755d
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+#include <stdlib.h>
+volatile int a, b;
+int c, d, e, f;
+
+static int
+fn1 ()
+{
+  if (b)
+    {
+      d++;
+      e = c || f;
+    }
+  return 0;
+}
+
+int
+main ()
+{
+  for (; a < 1; a++)
+    {
+      fn1 ();
+      continue;
+    }
+  if (d != 0)
+    abort();
+  return 0;
+}
index 36a879d1e7bb14d8b209ad20a63962347468c06d..98962c2fdecc8896b92fba9f116cee28edefd6f9 100644 (file)
@@ -1407,7 +1407,8 @@ is_cond_scalar_reduction (gimple phi, gimple *reduc,
   gimple stmt;
   gimple header_phi = NULL;
   enum tree_code reduction_op;
-  struct loop *loop = gimple_bb (phi)->loop_father;
+  basic_block bb = gimple_bb (phi);
+  struct loop *loop = bb->loop_father;
   edge latch_e = loop_latch_edge (loop);
   imm_use_iterator imm_iter;
   use_operand_p use_p;
@@ -1447,6 +1448,11 @@ is_cond_scalar_reduction (gimple phi, gimple *reduc,
   if (!is_predicated (gimple_bb (stmt)))
     return false;
 
+  /* Check that stmt-block is predecessor of phi-block.  */
+  if (EDGE_PRED (bb, 0)->src != gimple_bb (stmt)
+      && EDGE_PRED (bb, 1)->src != gimple_bb (stmt))
+    return false;
+
   if (!has_single_use (lhs))
     return false;