aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-12 15:34:37 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-12 15:34:37 +0000
commit88120a34aaeb91824759f238e2b227c54903ed44 (patch)
tree543e2a2d4fb5601fbfcf000ce3d6c5aa8b2c81ba
parent56363b234a6ea3c8da267667997b5a67f73ffe1a (diff)
2015-01-12 Richard Biener <rguenther@suse.de>
PR middle-end/64357 * tree-cfg.c (gimple_can_merge_blocks_p): Protect simple latches properly. * gcc.dg/torture/pr64357.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219473 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr64357.c34
-rw-r--r--gcc/tree-cfg.c6
4 files changed, 49 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c757e0b175a..dfba0bc433c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-12 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/64357
+ * tree-cfg.c (gimple_can_merge_blocks_p): Protect simple
+ latches properly.
+
2015-01-12 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* config/arm/arm.c (arm_cortex_a12_tune): Update entries to match
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6ff63449c80..3cda6b359a6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-12 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/64357
+ * gcc.dg/torture/pr64357.c: New testcase.
+
2015-01-12 H.J. Lu <hongjiu.lu@intel.com>
* gcc.target/i386/nop-mcount.c: Properly place {} in target
diff --git a/gcc/testsuite/gcc.dg/torture/pr64357.c b/gcc/testsuite/gcc.dg/torture/pr64357.c
new file mode 100644
index 00000000000..ff966efeeae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr64357.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+
+int a, b, c, d, e, f;
+
+long long
+fn1 (int p)
+{
+ return p ? p : 1;
+}
+
+static int
+fn2 ()
+{
+lbl:
+ for (; f;)
+ return 0;
+ for (;;)
+ {
+ for (b = 0; b; ++b)
+ if (d)
+ goto lbl;
+ c = e;
+ }
+}
+
+void
+fn3 ()
+{
+ for (; a; a = fn1 (a))
+ {
+ fn2 ();
+ e = 0;
+ }
+}
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index a9a2c2f7392..38e5e7db432 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1723,11 +1723,13 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
}
/* Protect simple loop latches. We only want to avoid merging
- the latch with the loop header in this case. */
+ the latch with the loop header or with a block in another
+ loop in this case. */
if (current_loops
&& b->loop_father->latch == b
&& loops_state_satisfies_p (LOOPS_HAVE_SIMPLE_LATCHES)
- && b->loop_father->header == a)
+ && (b->loop_father->header == a
+ || b->loop_father != a->loop_father))
return false;
/* It must be possible to eliminate all phi nodes in B. If ssa form