This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Kill def when folding immediate in two-addr pass
ClosedPublic

Authored by rampitec on Dec 2 2021, 2:28 PM.

Details

Summary

Two-address pass works right before RA and if an immediate
was folded into an instruction there is nothing to remove
the dead def. We end up with something like:

v_mov_b32_e32 v14, 0xc1700000
v_mov_b32_e32 v14, 0x41200000
v_fmaak_f32 v51, s67, v19, 0xc1700000
v_fmaak_f32 v38, v51, v19, 0x4120000

The patch kills the dead move instruction right in the folding.

Diff Detail

Event Timeline

rampitec created this revision.Dec 2 2021, 2:28 PM
rampitec requested review of this revision.Dec 2 2021, 2:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2021, 2:29 PM
Herald added a subscriber: wdng. · View Herald Transcript
rampitec updated this revision to Diff 391478.Dec 2 2021, 3:25 PM

Early return. NFC.

foad accepted this revision.Dec 3 2021, 1:29 AM

LGTM, I can't think of a better way of doing this.

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
3184

It's a shame that this IMPLICIT_DEF survives to the end of compilation and clutters the assembly output with "implicit-def:" comments.

This revision is now accepted and ready to land.Dec 3 2021, 1:29 AM
rampitec added inline comments.Dec 3 2021, 8:41 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
3184

Yes. Although the only way around it I see is to run MDCE one more time which seems to be an overkill to solve a cosmetic problem.

This revision was automatically updated to reflect the committed changes.