This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Remove old operand from VOPC DPP
ClosedPublic

Authored by Joe_Nash on Jul 18 2022, 1:51 PM.

Details

Summary

For most DPP instructions, the old operand stores the value that was in
the current lane before the DPP operation, and is tied to the
destination. For VOPC DPP, this is unnecessary and incorrect.

There appears to have been a latent bug related to D122737 with
SIInstrInfo::isOperandLegal. If you checked if a register operand was legal
when the InstructionDesc expected an immediate, it reported that is valid.
Its fix is necessary for and tested in this patch.

Diff Detail

Event Timeline

Joe_Nash created this revision.Jul 18 2022, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2022, 1:51 PM
Joe_Nash requested review of this revision.Jul 18 2022, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2022, 1:51 PM
This revision is now accepted and ready to land.Jul 18 2022, 3:03 PM
foad added inline comments.Jul 19 2022, 1:49 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
5022

I guess we want to return "true" here for a case like COPY, where the source operand should be a register but has no defined RC, but "false" for operands that should be immediates. Can we distinguish these cases by looking at the OpInfo?

Having said that, I guess returning false is OK for now. It's more conservative, just prevents some folding, and in the D122737 test case that does not matter because the unfolded copy get optimized away by register allocation anyway.

foad added inline comments.Jul 19 2022, 2:42 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
5022

Maybe return OpInfo.OperandType == MCOI::OPERAND_UNKNOWN;? That would preserve the existing behaviour for COPY.

Joe_Nash updated this revision to Diff 445802.Jul 19 2022, 6:53 AM
Joe_Nash marked 2 inline comments as done.

return OpInfo.OperandType == MCOI::OPERAND_UNKNOWN in isOperandLegal. For immediates gives false, for unspecified registers like in COPY gives true.

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

Nice idea, this seems to work.

foad accepted this revision.Jul 19 2022, 7:03 AM

LGTM, thanks.

This revision was landed with ongoing or failed builds.Jul 19 2022, 7:05 AM
This revision was automatically updated to reflect the committed changes.