From 4f912f91a095e78dc69ff875de4aeb41188c0655 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 15 Sep 2015 14:10:10 +0000 Subject: [PATCH] re PR tree-optimization/67470 (ICE at -O3 on x86_64-linux-gnu in compute_live_loop_exits, at tree-ssa-loop-manip.c:235) 2015-09-15 Richard Biener PR tree-optimization/67470 * tree-ssa-loop-im.c (execute_sm_if_changed): Preserve PHI structure for PHI hoisting by inserting a forwarder block if appropriate. * gcc.dg/torture/pr67470.c: New testcase. From-SVN: r227797 --- gcc/ChangeLog | 7 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr67470.c | 30 ++++++++++++++++++++++++++ gcc/tree-ssa-loop-im.c | 17 +++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr67470.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fda0151c22e..bc00735e07f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-09-15 Richard Biener + + PR tree-optimization/67470 + * tree-ssa-loop-im.c (execute_sm_if_changed): Preserve PHI + structure for PHI hoisting by inserting a forwarder block + if appropriate. + 2015-09-15 Christian Bruel * config/arm/arm.c (TARGET_OPTION_PRINT): Define. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6cea1084800..c8aa20a73a1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-09-15 Richard Biener + + PR tree-optimization/67470 + * gcc.dg/torture/pr67470.c: New testcase. + 2015-09-15 Alan Lawrence * gcc.target/aarch64/vect_int32x2x4_1.c: New. diff --git a/gcc/testsuite/gcc.dg/torture/pr67470.c b/gcc/testsuite/gcc.dg/torture/pr67470.c new file mode 100644 index 00000000000..29a23c2ee9b --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr67470.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ + +int a, b, *c, d, e; + +void abort (void); + +int +main () +{ + int f, *g, **h = &g; + for (; b;) + { + c = &a; + for (e = 0; e < 1; e++) + *h = 0; + for (; d; d++) + if (f) + *c = 0; + else + { + *c = e = 0; + *h = &a; + } + + if (a && !g) + abort (); + + } + return 0; +} diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index f1d4a8ce15c..f67b57d7f27 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -1839,6 +1839,23 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag) if (loop_has_only_one_exit) ex = split_block_after_labels (ex->dest); + else + { + for (gphi_iterator gpi = gsi_start_phis (ex->dest); + !gsi_end_p (gpi); gsi_next (&gpi)) + { + gphi *phi = gpi.phi (); + if (virtual_operand_p (gimple_phi_result (phi))) + continue; + + /* When the destination has a non-virtual PHI node with multiple + predecessors make sure we preserve the PHI structure by + forcing a forwarder block so that hoisting of that PHI will + still work. */ + split_edge (ex); + break; + } + } old_dest = ex->dest; new_bb = split_edge (ex); -- 2.30.2