This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix and extend vccz workarounds
ClosedPublic

Authored by foad on Nov 17 2020, 8:02 AM.

Details

Summary

We have workarounds for two different cases where vccz can get out of
sync with the value in vcc. This fixes them in two ways:

  1. Fix the case where the def of vcc was in a previous basic block, by

pessimistically assuming that vccz might be incorrect at a basic block
boundary.

  1. Fix the handling of pre-existing waitcnt instructions by calling

generateWaitcntInstBefore before examining ScoreBrackets to determine
whether there's an outstanding smem read operation.

Diff Detail

Event Timeline

foad created this revision.Nov 17 2020, 8:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2020, 8:02 AM
foad requested review of this revision.Nov 17 2020, 8:02 AM
arsenm added inline comments.Nov 17 2020, 9:07 AM
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
1478

Could you have DefVCCLo && DefVCCHi?

foad added inline comments.Nov 17 2020, 9:14 AM
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
1478

I'm not sure what you're asking. But this particular bit of logic (if defines vcc_lo or vcc_hi ... else if defines vcc ...) hasn't changed, it has just moved up from line 1488, and it was previously discussed here: https://reviews.llvm.org/D69661#inline-627569

arsenm added inline comments.Nov 17 2020, 9:16 AM
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
1478

I mean call definesRegister 2x instead of 3x

foad added inline comments.Nov 17 2020, 9:24 AM
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
1478

No, because a def of $vcc does not satisfy Inst.definesRegister(AMDGPU::VCC_LO) or Inst.definesRegister(AMDGPU::VCC_HI). And I'm relying on that here, otherwise the "else if" part would be dead code.

piotr added a subscriber: piotr.Nov 18 2020, 1:48 AM
piotr added inline comments.
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
1435–1442

Nit: braces around multi-line blocks?

foad updated this revision to Diff 306014.Nov 18 2020, 2:10 AM

Add braces.

arsenm accepted this revision.Nov 18 2020, 7:17 AM
This revision is now accepted and ready to land.Nov 18 2020, 7:17 AM
This revision was landed with ongoing or failed builds.Nov 18 2020, 7:28 AM
This revision was automatically updated to reflect the committed changes.