This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] enable scalar compare in truncate selection
ClosedPublic

Authored by alex-t on Aug 30 2021, 10:33 AM.

Details

Summary

Currently, the truncate selection dag node is expanded as a bitwise AND plus compare to 1. This change enables scalar comparison in the pattern if the truncate node is uniform.

Diff Detail

Event Timeline

alex-t created this revision.Aug 30 2021, 10:33 AM
alex-t requested review of this revision.Aug 30 2021, 10:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2021, 10:33 AM
Herald added a subscriber: wdng. · View Herald Transcript
rampitec added inline comments.Aug 30 2021, 5:01 PM
llvm/lib/Target/AMDGPU/SIInstructions.td
2112

I think we can later fold it into

s_bitcmp1_b32 $a, 0

I can confirm this resolves the Vulkan CTS failures caused by D106079.

alex-t added inline comments.Aug 31 2021, 7:33 AM
llvm/lib/Target/AMDGPU/SIInstructions.td
2112

For now, I would prefer to leave TODO here. Any objections?

rampitec added inline comments.Aug 31 2021, 9:43 AM
llvm/lib/Target/AMDGPU/SIInstructions.td
2112

No objections, I also do not think we have to select it this way, but rather combine later.

This revision is now accepted and ready to land.Aug 31 2021, 9:46 AM
rampitec added inline comments.Aug 31 2021, 12:19 PM
llvm/lib/Target/AMDGPU/SIInstructions.td
2112

What's interesting, S_AND_B32 will produce SCC = 1 on non-zero result just by itself! When you land it we may experiment with removing S_CMP from this pattern completely, although I am not sure how the rest of the BE prepared for the lack of compare and what would the pattern after propagating SCC from moveToVALU().

rampitec added inline comments.Aug 31 2021, 4:28 PM
llvm/lib/Target/AMDGPU/SIInstructions.td
2112

D109031 will remove compare and that is possible to extend it to use s_bitcmp. The latter will be generally beneficial for any scalar code checking a bitfield, not just this.

This revision was automatically updated to reflect the committed changes.