This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Process any power of 2 in optimizeCompareInstr
ClosedPublic

Authored by rampitec on Sep 2 2021, 3:39 PM.

Diff Detail

Event Timeline

rampitec created this revision.Sep 2 2021, 3:39 PM
rampitec requested review of this revision.Sep 2 2021, 3:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2021, 3:39 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm accepted this revision.Sep 2 2021, 4:55 PM
arsenm added inline comments.
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
8026

1 << n instead of 2^n?

This revision is now accepted and ready to land.Sep 2 2021, 4:55 PM
rampitec updated this revision to Diff 370451.Sep 2 2021, 5:06 PM
rampitec marked an inline comment as done.
  • Updated comment
  • Fixed tidy comment
arsenm accepted this revision.Sep 2 2021, 5:30 PM
This revision was landed with ongoing or failed builds.Sep 2 2021, 5:39 PM
This revision was automatically updated to reflect the committed changes.
foad added inline comments.Sep 3 2021, 3:05 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
8036

Yeah that is an ugly special case. Do we really need to handle ge/gt here at all? Can't we rely on something else canonicalizing them all to eq/ne comparisons?

8119

Isn't this just BitNo?

rampitec added inline comments.Sep 3 2021, 3:31 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
8036

It must be even uglier since llvm tends to change "a >= i" to "a > i - 1". So in practice it is canonicacalized to be not a power of 2 often. That is really so much interlinked...

In addition it tends to kill any known power of 2 by replacing it with a shift and comparing a low bit. I feel somewhat lost trying to deoptimize.

8119

Yes, silly. Too much changes and copy-paste.

rampitec marked an inline comment as done.Sep 3 2021, 11:32 AM
rampitec added inline comments.
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
8119