From e7089ecf1c8a67d5572ada8ecd3b3d99f420089c Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 18 Sep 2008 11:28:18 +0000 Subject: [PATCH] re PR middle-end/37456 (ICE: verify_flow_info failed: control flow in the middle of basic block) 2008-09-18 Richard Guenther PR tree-optimization/37456 * tree-ssa-reassoc.c (build_and_add_sum): If the stmt we want to insert after ends a BB insert on the single fallthru outgoing edge. * testsuite/g++.dg/torture/pr37456.C: New testcase. From-SVN: r140449 --- gcc/ChangeLog | 7 ++++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/torture/pr37456.C | 14 +++++++++++ gcc/tree-ssa-reassoc.c | 32 ++++++++++++++++++++++---- 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr37456.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bad3a253eb9..7d0282997d7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2008-09-18 Richard Guenther + + PR tree-optimization/37456 + * tree-ssa-reassoc.c (build_and_add_sum): If the stmt we + want to insert after ends a BB insert on the single fallthru + outgoing edge. + 2008-09-18 Andreas Krebbel * doc/invoke.texi: Document -mhard-dfp, -mno-hard-dfp. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7bbee66143a..cebd6736e5d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-09-18 Richard Guenther + + PR tree-optimization/37456 + * testsuite/g++.dg/torture/pr37456.C: New testcase. + 2008-09-18 Uros Bizjak PR rtl-optimization/37544 diff --git a/gcc/testsuite/g++.dg/torture/pr37456.C b/gcc/testsuite/g++.dg/torture/pr37456.C new file mode 100644 index 00000000000..cf2021be203 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr37456.C @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +int zot(int); +struct bar { + ~bar() { } +}; +int x; +void doit(int a, int b, int c) +{ + bar pn; + int b1 = zot(a) * c; + int b2 = zot(b) * c; + x = b1 + b2; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index e4e7db69d2e..bfe909d6738 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -859,8 +859,20 @@ build_and_add_sum (tree tmpvar, tree op1, tree op2, enum tree_code opcode) } else { - gsi = gsi_for_stmt (op2def); - gsi_insert_after (&gsi, sum, GSI_NEW_STMT); + if (!stmt_ends_bb_p (op2def)) + { + gsi = gsi_for_stmt (op2def); + gsi_insert_after (&gsi, sum, GSI_NEW_STMT); + } + else + { + edge e; + edge_iterator ei; + + FOR_EACH_EDGE (e, ei, gimple_bb (op2def)->succs) + if (e->flags & EDGE_FALLTHRU) + gsi_insert_on_edge_immediate (e, sum); + } } } else @@ -872,8 +884,20 @@ build_and_add_sum (tree tmpvar, tree op1, tree op2, enum tree_code opcode) } else { - gsi = gsi_for_stmt (op1def); - gsi_insert_after (&gsi, sum, GSI_NEW_STMT); + if (!stmt_ends_bb_p (op1def)) + { + gsi = gsi_for_stmt (op1def); + gsi_insert_after (&gsi, sum, GSI_NEW_STMT); + } + else + { + edge e; + edge_iterator ei; + + FOR_EACH_EDGE (e, ei, gimple_bb (op1def)->succs) + if (e->flags & EDGE_FALLTHRU) + gsi_insert_on_edge_immediate (e, sum); + } } } update_stmt (sum);