From 8c5fdaaefc5b028fed17e9cfca25f30867b1cf3b Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Tue, 24 May 2011 16:28:38 +0000 Subject: [PATCH] [multiple changes] 2011-05-24 Vladimir Makarov PR rtl-optimization/48633 * ira-build.c (loop_with_eh_edge_p): New function. (mark_loops_for_removal): Use it. 2011-05-24 Michael Matz PR rtl-optimization/48633 * g++.dg/pr48633.C: New test. From-SVN: r174124 --- gcc/ChangeLog | 8 +++++++- gcc/ira-build.c | 32 ++++++++++++++++++++++++++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr48633.C | 28 ++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr48633.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ee5f9f5f85c..91e550ae3be 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,10 @@ -2011-05-13 Vladimir Makarov +2011-05-24 Vladimir Makarov + + PR rtl-optimization/48633 + * ira-build.c (loop_with_eh_edge_p): New function. + (mark_loops_for_removal): Use it. + +2011-05-24 Vladimir Makarov PR rtl-optimization/48971 * ira.c (setup_pressure_classes): Don't check register move cost diff --git a/gcc/ira-build.c b/gcc/ira-build.c index 09897d95387..31d0199791a 100644 --- a/gcc/ira-build.c +++ b/gcc/ira-build.c @@ -1806,6 +1806,25 @@ low_pressure_loop_node_p (ira_loop_tree_node_t node) return true; } +/* Return TRUE if LOOP has a EH enter or exit edge. */ +static bool +loop_with_eh_edge_p (struct loop *loop) +{ + int i; + edge_iterator ei; + edge e; + VEC (edge, heap) *edges; + + FOR_EACH_EDGE (e, ei, loop->header->preds) + if (e->flags & EDGE_EH) + return true; + edges = get_loop_exit_edges (loop); + FOR_EACH_VEC_ELT (edge, edges, i, e) + if (e->flags & EDGE_EH) + return true; + return false; +} + /* Sort loops for marking them for removal. We put already marked loops first, then less frequent loops next, and then outer loops next. */ @@ -1829,14 +1848,18 @@ loop_compare_func (const void *v1p, const void *v2p) return l1->loop->num - l2->loop->num; } - /* Mark loops which should be removed from regional allocation. We remove a loop with low register pressure inside another loop with register pressure. In this case a separate allocation of the loop hardly helps (for irregular register file architecture it could help by choosing a better hard register in the loop but we prefer faster allocation even in this case). We also remove cheap loops - if there are more than IRA_MAX_LOOPS_NUM of them. */ + if there are more than IRA_MAX_LOOPS_NUM of them. Loop with EH + exit or enter edges are removed too because the allocation might + require put pseudo moves on the EH edges (we could still do this + for pseudos with caller saved hard registers in some cases but it + is impossible to say here or during top-down allocation pass what + hard register the pseudos get finally). */ static void mark_loops_for_removal (void) { @@ -1859,8 +1882,9 @@ mark_loops_for_removal (void) } sorted_loops[n++] = &ira_loop_nodes[i]; ira_loop_nodes[i].to_remove_p - = (low_pressure_loop_node_p (ira_loop_nodes[i].parent) - && low_pressure_loop_node_p (&ira_loop_nodes[i])); + = ((low_pressure_loop_node_p (ira_loop_nodes[i].parent) + && low_pressure_loop_node_p (&ira_loop_nodes[i])) + || loop_with_eh_edge_p (ira_loop_nodes[i].loop)); } qsort (sorted_loops, n, sizeof (ira_loop_tree_node_t), loop_compare_func); for (i = 0; n - i + 1 > IRA_MAX_LOOPS_NUM; i++) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bdc0f3e6422..beee8a6fbd6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-24 Michael Matz + + PR rtl-optimization/48633 + * g++.dg/pr48633.C: New test. + 2011-05-24 Uros Bizjak PR target/49133 diff --git a/gcc/testsuite/g++.dg/pr48633.C b/gcc/testsuite/g++.dg/pr48633.C new file mode 100644 index 00000000000..90f053a74c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr48633.C @@ -0,0 +1,28 @@ +/* { dg-do compile} */ +/* { dg-options "-O2 -fira-region=all -fnon-call-exceptions" } */ +extern long double getme (void); +extern void useme (long double); +struct Frame { + long double tmp; +}; +void bugme (int n, long double ld1, long double ld2, long double ld3, + long double ld4, long double ld5) +{ + Frame f; + int i; + f.tmp = getme(); + try { + for (i = 0; i < n; i++) + { + f.tmp += 1.0; + } + } catch (...) { + f.tmp += 1.0; + } + ld1++; + ld2++; + ld3++; + ld4++; + ld5++; + useme (f.tmp); +} -- 2.30.2