This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix a case of updating LiveIntervals in SIOptimizeExecMaskingPreRA
ClosedPublic

Authored by foad on Apr 6 2023, 9:29 AM.

Details

Summary

This was causing two test failures when I applied D129208 to enable
extra verification of LiveIntervals:

LLVM :: CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir
LLVM :: CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir

Diff Detail

Event Timeline

foad created this revision.Apr 6 2023, 9:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2023, 9:29 AM
foad requested review of this revision.Apr 6 2023, 9:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2023, 9:29 AM

I assume D129208 is the test case for this, so it does not need any new tests?

llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
109

Presumably this is just fixing an error in the original comment, i.e. NFC?

303

I take it we cannot simply move the first LIS->shrinkToUses(SelLI); after the if because the IsDead query depends on it?

foad added a comment.Apr 7 2023, 3:18 AM

I assume D129208 is the test case for this, so it does not need any new tests?

Yes that is my thinking. To test it in isolation I would need to tweak the RUN line in test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir to run another pass after si-optimize-exec-masking-pre-ra which depends on LiveIntervals having been preserved. I suppose I could try that, but it would become redundant again after D129208 lands.

llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
109

Right. I've committed it separately now: b2e98c18cc8abf2c1cc6a7f85c8708550cc8fd28

303

Yes. On a related note, instead of rolling our own IsDead test I wondered if we should use the form of shrinkToUses which returns a vector of dead instructions. I tried that but it was causing other CodeGen differences not strictly related to this bug fix so I gave up.

Going even further, perhaps we should be using something like LiveRangeEdit::eliminateDeadDefs which already has the logic to iterate calling shrinkToUses.

foad updated this revision to Diff 511652.Apr 7 2023, 3:19 AM

Rebase.

arsenm accepted this revision.Apr 7 2023, 3:40 PM
This revision is now accepted and ready to land.Apr 7 2023, 3:40 PM