aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr61385.c43
-rw-r--r--gcc/tree-ssa-phiopt.c4
4 files changed, 57 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7486ec0..ca574c0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-04 Marc Glisse <marc.glisse@inria.fr>
+
+ PR tree-optimization/61385
+ * tree-ssa-phiopt.c (value_replacement): Punt if there are PHI nodes.
+
2014-06-04 Bernd Schmidt <bernds@codesourcery.com>
* lto-wrapper.c (fatal, fatal_perror): Remove functions. All callers
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 883a2bd..e53501c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-04 Marc Glisse <marc.glisse@inria.fr>
+
+ PR tree-optimization/61385
+ * gcc.dg/tree-ssa/pr61385.c: New file.
+
2014-06-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/60098
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61385.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61385.c
new file mode 100644
index 0000000..f2e5a3c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61385.c
@@ -0,0 +1,43 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#define assert(x) if (!(x)) __builtin_abort ()
+
+int a, b, c, d, e, f, g;
+
+int
+fn1 ()
+{
+ int *h = &c;
+ for (; c < 1; c++)
+ {
+ int *i = &a, *k = &a;
+ f = 0;
+ if (b)
+ return 0;
+ if (*h)
+ {
+ int **j = &i;
+ *j = 0;
+ d = 0;
+ }
+ else
+ g = e = 0;
+ if (*h)
+ {
+ int **l = &k;
+ *l = &g;
+ }
+ d &= *h;
+ assert (k == &a || k);
+ assert (i);
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ fn1 ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index e3b6f1d..95844f4 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -849,6 +849,10 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
&& !POINTER_TYPE_P (TREE_TYPE (arg0))))
return 0;
+ /* Punt if there are (degenerate) PHIs in middle_bb, there should not be. */
+ if (!gimple_seq_empty_p (phi_nodes (middle_bb)))
+ return 0;
+
/* Only transform if it removes the condition. */
if (!single_non_singleton_phi_for_edges (phi_nodes (gimple_bb (phi)), e0, e1))
return 0;