diff options
author | Richard Biener <rguenther@suse.de> | 2017-01-23 22:29:17 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2017-01-23 15:29:17 -0700 |
commit | 108fdd6d848eb083021de4a43f3e682fa7babbf3 (patch) | |
tree | abeeed22e3f2d4c6218cc99541dddd430b990a67 /gcc/tree-ssa-threadupdate.c | |
parent | 01f26e0e1f69a8462e20a44eb9f15ae9c1b541fe (diff) | |
download | gcc-108fdd6d848eb083021de4a43f3e682fa7babbf3.zip gcc-108fdd6d848eb083021de4a43f3e682fa7babbf3.tar.gz gcc-108fdd6d848eb083021de4a43f3e682fa7babbf3.tar.bz2 |
re PR tree-optimization/79088 (wrong code at -O2 on x86_64-linux-gnu)
2017-01-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/79088
PR tree-optimization/79188
* tree-ssa-threadupdate.c (mark_threaded_blocks): Move code
resetting loop bounds after last path deletion. Reset loop
bounds of the target loop, make code match the comments.
* tree-ssa-threadbackwards.c (pass_early_thread_jumps::execute):
Make sure loops need no fixups.
* gcc.dg/torture/pr79088.c: New testcase.
* gcc.dg/torture/pr79188.c: Likewise.
From-SVN: r244837
Diffstat (limited to 'gcc/tree-ssa-threadupdate.c')
-rw-r--r-- | gcc/tree-ssa-threadupdate.c | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index f85fed3..8e08ae2 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -2086,42 +2086,6 @@ mark_threaded_blocks (bitmap threaded_blocks) else bitmap_copy (threaded_blocks, tmp); - /* Look for jump threading paths which cross multiple loop headers. - - The code to thread through loop headers will change the CFG in ways - that invalidate the cached loop iteration information. So we must - detect that case and wipe the cached information. */ - EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi) - { - basic_block bb = BASIC_BLOCK_FOR_FN (cfun, i); - FOR_EACH_EDGE (e, ei, bb->preds) - { - if (e->aux) - { - vec<jump_thread_edge *> *path = THREAD_PATH (e); - - for (unsigned int i = 0, crossed_headers = 0; - i < path->length (); - i++) - { - basic_block dest = (*path)[i]->e->dest; - basic_block src = (*path)[i]->e->src; - crossed_headers += (dest == dest->loop_father->header); - /* If we step from a block outside an irreducible region - to a block inside an irreducible region, then we have - crossed into a loop. */ - crossed_headers += ((src->flags & BB_IRREDUCIBLE_LOOP) - != (dest->flags & BB_IRREDUCIBLE_LOOP)); - if (crossed_headers > 1) - { - vect_free_loop_info_assumptions (dest->loop_father); - break; - } - } - } - } - } - /* If we have a joiner block (J) which has two successors S1 and S2 and we are threading though S1 and the final destination of the thread is S2, then we must verify that any PHI nodes in S2 have the same @@ -2166,6 +2130,46 @@ mark_threaded_blocks (bitmap threaded_blocks) } } + /* Look for jump threading paths which cross multiple loop headers. + + The code to thread through loop headers will change the CFG in ways + that invalidate the cached loop iteration information. So we must + detect that case and wipe the cached information. */ + EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi) + { + basic_block bb = BASIC_BLOCK_FOR_FN (cfun, i); + FOR_EACH_EDGE (e, ei, bb->preds) + { + if (e->aux) + { + vec<jump_thread_edge *> *path = THREAD_PATH (e); + + for (unsigned int i = 0, crossed_headers = 0; + i < path->length (); + i++) + { + basic_block dest = (*path)[i]->e->dest; + basic_block src = (*path)[i]->e->src; + /* If we enter a loop. */ + if (flow_loop_nested_p (src->loop_father, dest->loop_father)) + ++crossed_headers; + /* If we step from a block outside an irreducible region + to a block inside an irreducible region, then we have + crossed into a loop. */ + else if (! (src->flags & BB_IRREDUCIBLE_LOOP) + && (dest->flags & BB_IRREDUCIBLE_LOOP)) + ++crossed_headers; + if (crossed_headers > 1) + { + vect_free_loop_info_assumptions + ((*path)[path->length () - 1]->e->dest->loop_father); + break; + } + } + } + } + } + BITMAP_FREE (tmp); } |