diff mbox

[2/2] shrink wrap a function with a single loop: split live_edge

Message ID 541FF8D2.2070807@arm.com
State New
Headers show

Commit Message

Jiong Wang Sept. 22, 2014, 10:24 a.m. UTC
On 19/09/14 17:19, Jeff Law wrote:

> On 09/19/14 10:02, Jiong Wang wrote:
>> On 19/09/14 16:49, Jeff Law wrote:
>>>
>>> Probably.  Though I'd be a bit concerned with next_block->next_bb.
>>> Wouldn't it be safer to stash away the relevant basic block prior to the
>>> call to split_edge, then use that saved copy.  Something like this
>>> (untested):
>>>
>>> basic_block old_dest = live_edge->dest;
>>> next_block = split_edge (live_edge);
>>>
>>> /* We create a new basic block.  Call df_grow_bb_info to make sure
>>>       all data structures are allocated.  */
>>> df_grow_bb_info (df_live);
>>> bitmap_and (df_get_live_in (next_block),
>>>                df_get_live_out (bb),
>>>                df_get_live_in (old_dest));
>>>
>>>
>>> The idea being we don't want to depend on the precise ordering blocks in
>>> the block chain.
>>>
>>> Could you try that and see if it does what you need?
>> Jeff,
>>
>>     Thanks, verified, it works.
> Great.  Can you send an updated patchkit for review.

patch attached.

please review, thanks.

gcc/
   * shrink-wrap.c (move_insn_for_shrink_wrap): Initialize the live-in of
   new created BB as the intersection of live-in from "old_dest" and live-out
   from "bb".

Comments

Jeff Law Sept. 22, 2014, 5:51 p.m. UTC | #1
On 09/22/14 04:24, Jiong Wang wrote:
>> Great.  Can you send an updated patchkit for review.
>
> patch attached.
>
> please review, thanks.
>
> gcc/ * shrink-wrap.c (move_insn_for_shrink_wrap): Initialize the
> live-in of new created BB as the intersection of live-in from
> "old_dest" and live-out from "bb".
Looks good.  However, before committing we need a couple things.

1. Bootstrap & regression test this variant of the patch.  I know you 
tested an earlier one, but please test this one just to be sure.

2. Testcase.  I think you could test for either the reduction in the 
live-in set of the newly created block or that you're shrink wrapping 
one or more functions you didn't previously shrink-wrap.  I think it's 
fine if this test is target specific.

Jeff
diff mbox

Patch

diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
index fd24135..63deadf 100644
--- a/gcc/shrink-wrap.c
+++ b/gcc/shrink-wrap.c
@@ -217,12 +217,15 @@  move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn,
       if (!df_live)
 	return false;

+      basic_block old_dest = live_edge->dest;
       next_block = split_edge (live_edge);

       /* We create a new basic block.  Call df_grow_bb_info to make sure
 	 all data structures are allocated.  */
       df_grow_bb_info (df_live);
-      bitmap_copy (df_get_live_in (next_block), df_get_live_out (bb));
+
+      bitmap_and (df_get_live_in (next_block), df_get_live_out (bb),
+		  df_get_live_in (old_dest));
       df_set_bb_dirty (next_block);

       /* We should not split more than once for a function.  */