Commit b89410ef by Jeff Law

[PATCH] Avoid more irreducible loops in FSM threader

	* tree-ssa-threadupdate.c (valid_jump_thread_path): Also detect
	cases where the loop latch edge is in the middle of an FSM
	path.

	* gcc.dg/tree-ssa/ssa-thread-11.c: Verify that we do not have
	irreducible loops in the CFG.

From-SVN: r229685
parent 58b2d87e
2015-11-02 Jeff Law <jeff@redhat.com>
* tree-ssa-threadupdate.c (valid_jump_thread_path): Also detect
cases where the loop latch edge is in the middle of an FSM
path.
2015-11-03 Tom de Vries <tom@codesourcery.com> 2015-11-03 Tom de Vries <tom@codesourcery.com>
* tree-ssa-structalias.c (make_restrict_var_constraints): Rename to ... * tree-ssa-structalias.c (make_restrict_var_constraints): Rename to ...
2015-11-02 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/ssa-thread-11.c: Verify that we do not have
irreducible loops in the CFG.
2015-11-02 Alan Lawrence <alan.lawrence@arm.com> 2015-11-02 Alan Lawrence <alan.lawrence@arm.com>
Revert: Revert:
......
/* { dg-do compile { target { ! { logical_op_short_circuit || { m68k*-*-* mep*-*-* bfin*-*-* v850*-*-* moxie*-*-* m32c*-*-* fr30*-*-* mcore*-*-* frv-*-* h8300-*-* m32r-*-* mn10300-*-* msp430-*-* pdp11-*-* rl78-*-* rx-*-* vax-*-*} } } } } */ /* { dg-do compile { target { ! { logical_op_short_circuit || { m68k*-*-* mep*-*-* bfin*-*-* v850*-*-* moxie*-*-* m32c*-*-* fr30*-*-* mcore*-*-* frv-*-* h8300-*-* m32r-*-* mn10300-*-* msp430-*-* pdp11-*-* rl78-*-* rx-*-* vax-*-*} } } } } */
/* { dg-options "-O2 -fdump-tree-vrp2-details" } */ /* { dg-options "-O2 -fdump-tree-vrp2-details" } */
/* { dg-final { scan-tree-dump-not "IRREDUCIBLE_LOOP" "vrp2" } } */
/* { dg-final { scan-tree-dump "FSM" "vrp2" } } */ /* { dg-final { scan-tree-dump "FSM" "vrp2" } } */
void abort (void); void abort (void);
......
...@@ -2547,29 +2547,38 @@ valid_jump_thread_path (vec<jump_thread_edge *> *path) ...@@ -2547,29 +2547,38 @@ valid_jump_thread_path (vec<jump_thread_edge *> *path)
{ {
unsigned len = path->length (); unsigned len = path->length ();
bool multiway_branch = false; bool multiway_branch = false;
bool threaded_through_latch = false;
/* Check that the path is connected and see if there's a multi-way /* Check that the path is connected and see if there's a multi-way
branch on the path. */ branch on the path. */
for (unsigned int j = 0; j < len - 1; j++) for (unsigned int j = 0; j < len - 1; j++)
{ {
if ((*path)[j]->e->dest != (*path)[j+1]->e->src) edge e = (*path)[j]->e;
struct loop *loop = e->dest->loop_father;
if (e->dest != (*path)[j+1]->e->src)
return false; return false;
gimple *last = last_stmt ((*path)[j]->e->dest);
/* If we're threading through the loop latch back into the
same loop and the destination does not dominate the loop
latch, then this thread would create an irreducible loop. */
if (loop->latch
&& loop_latch_edge (loop) == e
&& loop == path->last()->e->dest->loop_father
&& (determine_bb_domination_status (loop, path->last ()->e->dest)
== DOMST_NONDOMINATING))
threaded_through_latch = true;
gimple *last = last_stmt (e->dest);
multiway_branch |= (last && gimple_code (last) == GIMPLE_SWITCH); multiway_branch |= (last && gimple_code (last) == GIMPLE_SWITCH);
} }
/* If we are trying to thread the loop latch to a block that does /* If we are trying to thread through the loop latch to a block in the
not dominate the loop latch, then that will create an irreducible loop that does not dominate the loop latch, then that will create an
loop. We avoid that unless the jump thread has a multi-way irreducible loop. We avoid that unless the jump thread has a multi-way
branch, in which case we have deemed it worth losing other branch, in which case we have deemed it worth losing other
loop optimizations later if we can eliminate the multi-way branch. */ loop optimizations later if we can eliminate the multi-way branch. */
edge e = (*path)[0]->e; if (!multiway_branch && threaded_through_latch)
struct loop *loop = e->dest->loop_father;
if (!multiway_branch
&& loop->latch
&& loop_latch_edge (loop) == e
&& (determine_bb_domination_status (loop, path->last ()->e->dest)
== DOMST_NONDOMINATING))
return false; return false;
return true; return true;
......
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