This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question on updating DF info during code hoisting


On Mon, Oct 22, 2012 at 6:25 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Bin.Cheng wrote:
>> It is possible to have register pressure decreased when hoisting an
>> expression up in flow graph because of shrunk live range of input
>> register operands.
>> To accurately simulating the change of register pressure, I have to
>> check the change of live range of input operands during hoisting. For
>> example, to hoist "x+y" through a basic block B up in flow graph, I
>> have to:
>> 1. Check whether x/y is in DF_LR_OUT(B), it yes, the live range won't be shrunk.
>
> in df_get_live_out(B). That uses DF_LIVE instead of DF_LR if DF_LIVE
> is available. That's the more optimistic liveness definition where
> something that's used but not defined is not considered live.
>
>
>> 2. Check whether x/y is referred by any other insns in B, if yes, the
>> live range won't be shrunk. Basically I have two methods to do this:
>>     a) Iterate over insns in B reversely, checking whether x/y is
>> referred by the insn.
>>     b) Iterate over all references of x/y(using
>> DF_REG_USE_CHAIN(REGNO(x/y))), checking whether the reference is made
>> in B.
>>
>> Method A) is simple, but I guess it would be expensive and I am
>> thinking about using method B).
>
> Method B should be fine for pseudo-registers, they tend to have few
> uses i.e. short chains.
>
>
>> The problem is code hoisting itself create/modify/delete insns in
>> basic block, I have to update DF cache info each time an expression is
>> hoisted thus the info can be used to check the change of live range
>> when hoisting other expressions later.
>>
>> Though not familiar with DF in GCC, I think I can use
>> df_insn_delete/df_insn_rescan to update DF caches for newly
>> modified/deleted instructions.
>
> If you delete an insn, most of this happens automatically, unless you
> use the DF_DEFER_INSN_RESCAN or DF_NO_INSN_RESCAN flags. But these are
> not used in gcse.c so the DF caches are updated on-the-fly. No need to
> use df_insn_delete/df_insn_rescan manually unless you change an insn
> in-place without going through recog.c (validate_change and friends).
>
>
>> What I am not sure are:
>> 1. Basically I only need to update the reference information(i.e.,
>> DF_REG_USE_CHAIN(REGNO(x/y))) for each input operand and don't
>>  need to
>> update global DF_LR_IN/OUT information(because this will be done
>> manually when trying to hoist an expression). Could this be done in
>> current DF infrastructure?
>
> This should already be happening. But you should update the stuff you
> get back from df_get_live_{in,out}, not DF_LR_{IN,OUT}.
>
>
>> 2. I did not find any DF interface to calculate reference information
>> for newly created insn, so how could I do this?
>
> Should also already be happening on-the-fly.
>

Thanks for your explanation.
Now I understand how df_insn_info is updated when
deleting/modifying/creating insn. One more question is when and how
IN/OUT information is updated. GCC calls df_set_bb_dirty when handling
insns, but I did not found any spot in GCSE updating that information.
is it done in CFG_CLEANUP?

I would like to study DF infrastructure later, could you share some
background knowledge on this, for example theory/algorithms to which
GCC referred. Though there is good comment at the beginning of
df-core.c, it doesn't mention any background/references.

Thanks.

-- 
Best Regards.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]