This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/SI: Only look at live out SGPR defs
ClosedPublic

Authored by arsenm on Aug 8 2015, 7:05 PM.

Details

Reviewers
tstellarAMD
Summary

When trying to fix SGPR live ranges, skip defs that are
killed in the same block as the def. I don't think
we need to worry about these cases as long as the
live ranges of the SGPRs in dominating blocks are
correct.

This reduces the number of elements the second
loop over the function needs to look at, and makes
it generally easier to understand. The second loop
also only considers if the live range is live
in to a block, which logically means it
must have been live out from another.

Diff Detail

Event Timeline

arsenm updated this revision to Diff 31605.Aug 8 2015, 7:05 PM
arsenm retitled this revision from to AMDGPU/SI: Only look at live out SGPR defs.
arsenm updated this object.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: llvm-commits.

When trying to fix SGPR live ranges, skip defs that are
killed in the same block as the def. I don't think
we need to worry about these cases as long as the
live ranges of the SGPRs in dominating blocks are
correct.

I think this will break this case:

def vreg0 <- assigned sgpr0

if:
def vreg1 <- assigned sgpr0
kill vreg1 <- assigned sgpr0
br endif

else:
use vreg0 <- assigned sgpr0
br endif

endif:
...

It doesn't look like phab picked up your email response, so I'm reproducing it here:

I’m not sure I see why. vreg0 is live out of the entry block, so it will have it’s range extended until after the endif, so I don’t think it can be assigned to the same register as vreg1

Ok, so you are saying this won't be a problem as long as we correctly extend the live range of vreg0. That makes sense. I would like to test this patch before it is committed.

It doesn't look like phab picked up your email response, so I'm reproducing it here:

I’m not sure I see why. vreg0 is live out of the entry block, so it will have it’s range extended until after the endif, so I don’t think it can be assigned to the same register as vreg1

Ok, so you are saying this won't be a problem as long as we correctly extend the live range of vreg0. That makes sense. I would like to test this patch before it is committed.

In this example the live range of vreg1 wouldn't have been changed anyway because the if block only has one successor. I don't think this patch actually changes the insertion behavior.

tstellarAMD accepted this revision.Aug 14 2015, 6:38 PM
tstellarAMD edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Aug 14 2015, 6:38 PM
arsenm closed this revision.Aug 14 2015, 7:59 PM

r245150