This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Extend pre-emit peephole to redundantly masked VCC
ClosedPublic

Authored by critson on Feb 19 2022, 8:09 PM.

Details

Summary

Extend pre-emit peephole for S_CBRANCH_VCC[N]Z to eliminate
redundant S_AND operations against EXEC for V_CMP results in VCC.
These occur after after register allocation when VCC has been
selected as the comparison destination.

Diff Detail

Event Timeline

critson created this revision.Feb 19 2022, 8:09 PM
critson requested review of this revision.Feb 19 2022, 8:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2022, 8:09 PM

LGTM, but misses new tests in the insert-skip-from-vcc.mir.

Can you add some MIR tests, plus add a test for V_CMP_CLASS where this should also work

critson updated this revision to Diff 410446.Feb 21 2022, 9:40 PM
  • Add V_CMP_CLASS support
  • Add MIR tests
foad added a comment.Feb 22 2022, 2:55 AM

Extend pre-emit peephole for S_CBRANCH_VCC[N]Z to eliminate
redundant S_AND operations against EXEC for V_CMP results in VCC.

No particular objection to this patch, but it would be nice to do this more generally for comparison results that are not in vcc too.

arsenm added inline comments.Feb 22 2022, 8:25 AM
llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp
148

I think isCompare is always redundant with isVOPC

This revision is now accepted and ready to land.Feb 22 2022, 8:25 AM
This revision was landed with ongoing or failed builds.Feb 24 2022, 5:19 PM
This revision was automatically updated to reflect the committed changes.
critson marked an inline comment as done.
critson added inline comments.Feb 24 2022, 5:25 PM
llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp
148

Switched to using only isVOPC and documented why in a comment.

arsenm added inline comments.Feb 25 2022, 7:48 AM
llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp
149

isVOPC is redundant with isVALU