Commit c15bc84b by Eric Botcazou Committed by Eric Botcazou

re PR tree-optimization/18707 (Performance regression at -O2 with gzip)

	PR tree-optimization/18707
	* cfgloopmanip.c (create_preheader): Move the preheader
	only if the latch was falling through to the header.

Co-Authored-By: Roger Sayle <roger@eyesopen.com>

From-SVN: r92282
parent 59b1a766
2004-12-16 Eric Botcazou <ebotcazou@libertysurf.fr>
Roger Sayle <roger@eyesopen.com>
PR tree-optimization/18707
* cfgloopmanip.c (create_preheader): Move the preheader
only if the latch was falling through to the header.
2004-12-16 Danny Smith <dannysmith@users.sourceforge.net> 2004-12-16 Danny Smith <dannysmith@users.sourceforge.net>
PR target/18997 PR target/18997
......
...@@ -1142,6 +1142,8 @@ create_preheader (struct loop *loop, int flags) ...@@ -1142,6 +1142,8 @@ create_preheader (struct loop *loop, int flags)
struct loop *cloop, *ploop; struct loop *cloop, *ploop;
int nentry = 0; int nentry = 0;
bool irred = false; bool irred = false;
bool latch_edge_was_fallthru;
edge one_succ_pred = 0;
edge_iterator ei; edge_iterator ei;
cloop = loop->outer; cloop = loop->outer;
...@@ -1152,6 +1154,8 @@ create_preheader (struct loop *loop, int flags) ...@@ -1152,6 +1154,8 @@ create_preheader (struct loop *loop, int flags)
continue; continue;
irred |= (e->flags & EDGE_IRREDUCIBLE_LOOP) != 0; irred |= (e->flags & EDGE_IRREDUCIBLE_LOOP) != 0;
nentry++; nentry++;
if (EDGE_COUNT (e->src->succs) == 1)
one_succ_pred = e;
} }
gcc_assert (nentry); gcc_assert (nentry);
if (nentry == 1) if (nentry == 1)
...@@ -1166,6 +1170,7 @@ create_preheader (struct loop *loop, int flags) ...@@ -1166,6 +1170,7 @@ create_preheader (struct loop *loop, int flags)
} }
mfb_kj_edge = loop_latch_edge (loop); mfb_kj_edge = loop_latch_edge (loop);
latch_edge_was_fallthru = (mfb_kj_edge->flags & EDGE_FALLTHRU) != 0;
fallthru = make_forwarder_block (loop->header, mfb_keep_just, fallthru = make_forwarder_block (loop->header, mfb_keep_just,
mfb_update_loops); mfb_update_loops);
dummy = fallthru->src; dummy = fallthru->src;
...@@ -1177,13 +1182,23 @@ create_preheader (struct loop *loop, int flags) ...@@ -1177,13 +1182,23 @@ create_preheader (struct loop *loop, int flags)
if (ploop->latch == dummy) if (ploop->latch == dummy)
ploop->latch = fallthru->dest; ploop->latch = fallthru->dest;
/* Reorganize blocks so that the preheader is not stuck in the middle of the /* Try to be clever in placing the newly created preheader. The idea is to
loop. */ avoid breaking any "fallthruness" relationship between blocks.
/* Get an edge that is different from the one from loop->latch to The preheader was created just before the header and all incoming edges
dummy. */ to the header were redirected to the preheader, except the latch edge.
e = EDGE_PRED (dummy, EDGE_PRED (dummy, 0)->src == loop->latch); So the only problematic case is when this latch edge was a fallthru
move_block_after (dummy, e->src); edge: it is not anymore after the preheader creation so we have broken
the fallthruness. We're therefore going to look for a better place. */
if (latch_edge_was_fallthru)
{
if (one_succ_pred)
e = one_succ_pred;
else
e = EDGE_PRED (dummy, 0);
move_block_after (dummy, e->src);
}
loop->header->loop_father = loop; loop->header->loop_father = loop;
add_bb_to_loop (dummy, cloop); add_bb_to_loop (dummy, cloop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment