> On 19 Dec 2017, at 16:27, Jeff Law <l...@redhat.com> wrote:
> 
> On 12/19/2017 03:12 AM, Alan Hayward wrote:
>> Ping ping.
>> I think there should be enough information in the first test to show that 
>> any "set to self”
>> registers become live. Let me know if there’s anything I’ve missed.
> I think that both Richi and I would like you investigate fixing the df
> infrastructure so that a self-set doesn't make things go live.  Sorry if
> we weren't clear about that.  ie, level of complexity and likely fallout
> so that we can evaluate that vs CLOBBER_HIGH.
> 
> 
> 
> jeff
> 


Right, sorry, I misunderstood. Ok, so I’ve been looking at trying to do this.

To summarise: To do this we need to check for 1) All reg sets to self where 2) 
the existing value of the register fits within the mode of the new set. In 
these cases we want then to (in effect) pretend the set doesn’t exist.
To test this, I add a set to self in a tls_desc call for every V register ( eg: 
(set (reg:TI V0_REGNUM) (reg:TI V0_REGNUM)), (set (reg:TI V1_REGNUM) (reg:TI 
V1_REGNUM))  etc etc). If the patch works, then these registers will not be 
backed up around a tls call.

First added some checks into df-scan and successfully stopped the sets to self 
from being added to the live and uses lists.  [ To simplify the issue for now I 
ignored the existing value of the register, and just assumed it fits ].
However, running my test case, the code still results in my vector registers 
being backed up around tls. Even though the dumps show that my vector registers 
are no longer live.

Debugging further, finds that the register backing up is happening as part of 
combine.c. Ok, I can add a check for reg set to self in here too…..
But as part of my clobber_high patch I already had code in clobber.c that 
checked for CLOBBER_HIGH and then checked the mode of the previous value in the 
register. My new code ends up looking very similar to my clobber high patch.

Instead of:

if (GET_CODE (setter) == CLOBBER_HIGH
    && reg_is_clobbered_by_clobber_high(REGNO(dest), GET_MODE 
(rsp->last_set_value))

Now becomes something like:

if (GET_CODE (setter) == SET
    && REG_P (dest) && HARD_REGISTER_P (dest) && REG_P (src) && REGNO(dst) == 
REGNO(src)
    && reg_is_clobbered_by_self_set(REGNO(dest), GET_MODE (rsp->last_set_value))

I then need to find the next pass that has similar checks…. and again it’ll be 
the same places I already have clobber high code.

I suspect in the end I’ll be able to remove the df-scan changes, because as I 
effectively found out with clobber high, they aren’t causing any register 
backups to happen.

Ok, in the new patch we do save a bit of code because there is no new 
expression to add. But that was a small part of the full patch.

I could rewrite the patch in this way, but personally I feel it’s now 
exploiting a side effect of a set to self, rather than being explicit in what 
it is trying to do. 


Alan.

Reply via email to