This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix lowering of @llvm.amdgcn.set.inactive(imm, poison)
ClosedPublic

Authored by foad on May 22 2023, 7:45 AM.

Details

Summary

If the second argument of V_SET_INACTIVE is undef/poison,
SIWholeQuadMode lowered it to a COPY from the first argument, but that
caused invalid MIR if the first argument was an immediate rather than a
register.

Fix this by lowering to a V_MOV instruction instead of a COPY.

Fixes https://github.com/llvm/llvm-project/issues/62862

Diff Detail

Event Timeline

foad created this revision.May 22 2023, 7:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 7:45 AM
foad requested review of this revision.May 22 2023, 7:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 7:45 AM
foad added inline comments.
llvm/test/CodeGen/AMDGPU/wqm.ll
1179 ↗(On Diff #524309)

Ugh. So using MOV handled the copy-immediate-to-register case nicely, but apparently does not optimize away register-to-same-register copies. Any ideas for a neat way of handling both cases?

foad updated this revision to Diff 524319.May 22 2023, 8:02 AM

Use COPY for reg-reg but MOV for reg-imm.

arsenm added inline comments.May 22 2023, 8:09 AM
llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp
1546

If this is to use a v_mov_b32 it will be left without the implicit exec

foad added inline comments.May 22 2023, 8:17 AM
llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp
1546

No, the V_SET_INACTIVE has an implicit exec use, and we don't remove it.

arsenm accepted this revision.May 22 2023, 8:21 AM
arsenm added inline comments.
llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp
1546

Leaving copy with exec is also weird, and we're totally inconsistent on whether that's required and where

This revision is now accepted and ready to land.May 22 2023, 8:21 AM
This revision was landed with ongoing or failed builds.May 22 2023, 8:31 AM
This revision was automatically updated to reflect the committed changes.