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


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.

Ciao!
Steven


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