diff options
author | Bin Cheng <bin.cheng@arm.com> | 2017-10-10 09:02:13 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2017-10-10 09:02:13 +0000 |
commit | efe040bf219da9f0aa2298c19909e392c784b3d3 (patch) | |
tree | 5c6a56e26a252305e9ecc5ca13b46e9a1ac73b42 /gcc/tree-loop-distribution.c | |
parent | 166b87998a85c8c7d6db923bc7c8370af3665381 (diff) | |
download | gcc-efe040bf219da9f0aa2298c19909e392c784b3d3.zip gcc-efe040bf219da9f0aa2298c19909e392c784b3d3.tar.gz gcc-efe040bf219da9f0aa2298c19909e392c784b3d3.tar.bz2 |
tree-loop-distribution.c (generate_loops_for_partition): Remove inner loop's exit stmt by making it always exit the loop...
* tree-loop-distribution.c (generate_loops_for_partition): Remove
inner loop's exit stmt by making it always exit the loop, otherwise
we would generate an infinite empty loop.
gcc/testsuite
* gcc.dg/tree-ssa/ldist-27.c: New test.
From-SVN: r253580
Diffstat (limited to 'gcc/tree-loop-distribution.c')
-rw-r--r-- | gcc/tree-loop-distribution.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 3db3d6e..999b32e 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -830,6 +830,10 @@ generate_loops_for_partition (struct loop *loop, partition *partition, for (i = 0; i < loop->num_nodes; i++) { basic_block bb = bbs[i]; + edge inner_exit = NULL; + + if (loop != bb->loop_father) + inner_exit = single_exit (bb->loop_father); for (gphi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);) { @@ -848,11 +852,17 @@ generate_loops_for_partition (struct loop *loop, partition *partition, && !is_gimple_debug (stmt) && !bitmap_bit_p (partition->stmts, gimple_uid (stmt))) { - /* Choose an arbitrary path through the empty CFG part - that this unnecessary control stmt controls. */ + /* In distribution of loop nest, if bb is inner loop's exit_bb, + we choose its exit edge/path in order to avoid generating + infinite loop. For all other cases, we choose an arbitrary + path through the empty CFG part that this unnecessary + control stmt controls. */ if (gcond *cond_stmt = dyn_cast <gcond *> (stmt)) { - gimple_cond_make_false (cond_stmt); + if (inner_exit && inner_exit->flags & EDGE_TRUE_VALUE) + gimple_cond_make_true (cond_stmt); + else + gimple_cond_make_false (cond_stmt); update_stmt (stmt); } else if (gimple_code (stmt) == GIMPLE_SWITCH) |