Page MenuHomePhabricator

[AMDGPU] Fix FoldImmediate for 16 bit operand
ClosedPublic

Authored by rampitec on May 4 2020, 12:52 PM.

Diff Detail

Event Timeline

rampitec created this revision.May 4 2020, 12:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2020, 12:52 PM
arsenm added inline comments.May 4 2020, 1:45 PM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
2514

I think just checking op 0 is sufficient

llvm/test/CodeGen/AMDGPU/fold_16bit_imm.mir
2

Probably should generate these checks

13

Adding a use instruction for all of these wouldn't hurt in case peephole-opt ever decides to prune dead instructions

110

Needs test with skipped hi16

rampitec updated this revision to Diff 261949.May 4 2020, 3:45 PM
rampitec marked 5 inline comments as done.

Addressed review comments.
Added processing of hi16 src subreg, it is just an imm shift.

rampitec updated this revision to Diff 261952.May 4 2020, 4:16 PM

Always drop target flags on source operand. SubReg and TargetFlags share the same field changing the meaning depending on the operand type. If I do not drop it I get something like:

S_MOV_B32 target-flags(amdgpu-gotprel32-lo) 2048

Technically it could happen with 32 subregs as well, although does not seem to happen.

vpykhtin accepted this revision.May 5 2020, 1:46 AM

LGTM.

This revision is now accepted and ready to land.May 5 2020, 1:46 AM
This revision was automatically updated to reflect the committed changes.