Commit 4752be46 by Tom de Vries Committed by Tom de Vries

Don't tail-merge blocks from different loops

2017-07-03  Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/81192
	* tree-ssa-tail-merge.c (same_succ_hash): Use bb->loop_father->num in
	hash.
	(same_succ::equal): Don't find bbs to be equal if bb->loop_father
	differs.
	(find_same_succ_bb): Remove obsolete test on bb->loop_father->latch.

	* gcc.dg/pr81192.c: Update.

From-SVN: r249894
parent 0bbfd554
2017-07-03 Tom de Vries <tom@codesourcery.com> 2017-07-03 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/81192 PR tree-optimization/81192
* tree-ssa-tail-merge.c (same_succ_hash): Use bb->loop_father->num in
hash.
(same_succ::equal): Don't find bbs to be equal if bb->loop_father
differs.
(find_same_succ_bb): Remove obsolete test on bb->loop_father->latch.
2017-07-03 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/81192
* tree-ssa-tail-merge.c (same_succ_flush_bb): Handle * tree-ssa-tail-merge.c (same_succ_flush_bb): Handle
BB_SAME_SUCC (bb) == NULL. BB_SAME_SUCC (bb) == NULL.
......
2017-07-03 Tom de Vries <tom@codesourcery.com> 2017-07-03 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/81192 PR tree-optimization/81192
* gcc.dg/pr81192.c: Update.
2017-07-03 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/81192
* gcc.dg/pr81192.c: New test. * gcc.dg/pr81192.c: New test.
2017-07-02 Thomas Koenig <tkoenig@gcc.gnu.org> 2017-07-02 Thomas Koenig <tkoenig@gcc.gnu.org>
......
...@@ -19,4 +19,4 @@ fn2 (void) ...@@ -19,4 +19,4 @@ fn2 (void)
; ;
} }
/* { dg-final { scan-tree-dump-times "(?n)find_duplicates: <bb .*> duplicate of <bb .*>" 1 "pre" } } */ /* { dg-final { scan-tree-dump-not "(?n)find_duplicates: <bb .*> duplicate of <bb .*>" "pre" } } */
...@@ -479,6 +479,8 @@ same_succ_hash (const same_succ *e) ...@@ -479,6 +479,8 @@ same_succ_hash (const same_succ *e)
hstate.add_int (size); hstate.add_int (size);
BB_SIZE (bb) = size; BB_SIZE (bb) = size;
hstate.add_int (bb->loop_father->num);
for (i = 0; i < e->succ_flags.length (); ++i) for (i = 0; i < e->succ_flags.length (); ++i)
{ {
flags = e->succ_flags[i]; flags = e->succ_flags[i];
...@@ -568,6 +570,9 @@ same_succ::equal (const same_succ *e1, const same_succ *e2) ...@@ -568,6 +570,9 @@ same_succ::equal (const same_succ *e1, const same_succ *e2)
if (BB_SIZE (bb1) != BB_SIZE (bb2)) if (BB_SIZE (bb1) != BB_SIZE (bb2))
return 0; return 0;
if (bb1->loop_father != bb2->loop_father)
return 0;
gsi1 = gsi_start_nondebug_bb (bb1); gsi1 = gsi_start_nondebug_bb (bb1);
gsi2 = gsi_start_nondebug_bb (bb2); gsi2 = gsi_start_nondebug_bb (bb2);
gsi_advance_fw_nondebug_nonlocal (&gsi1); gsi_advance_fw_nondebug_nonlocal (&gsi1);
...@@ -695,15 +700,7 @@ find_same_succ_bb (basic_block bb, same_succ **same_p) ...@@ -695,15 +700,7 @@ find_same_succ_bb (basic_block bb, same_succ **same_p)
edge_iterator ei; edge_iterator ei;
edge e; edge e;
if (bb == NULL if (bb == NULL)
/* Be conservative with loop structure. It's not evident that this test
is sufficient. Before tail-merge, we've just called
loop_optimizer_finalize, and LOOPS_MAY_HAVE_MULTIPLE_LATCHES is now
set, so there's no guarantee that the loop->latch value is still valid.
But we assume that, since we've forced LOOPS_HAVE_SIMPLE_LATCHES at the
start of pre, we've kept that property intact throughout pre, and are
keeping it throughout tail-merge using this test. */
|| bb->loop_father->latch == bb)
return; return;
bitmap_set_bit (same->bbs, bb->index); bitmap_set_bit (same->bbs, bb->index);
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
......
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