This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Expand not pattern according to the XOR node divergence
ClosedPublic

Authored by alex-t on Dec 16 2021, 9:03 AM.

Details

Summary

The "not" is defined as XOR $src -1.
We need to transform this pattern to either S_NOT_B32 or V_NOT_B32_e32
dependent on the "xor" node divergence.

Diff Detail

Event Timeline

alex-t created this revision.Dec 16 2021, 9:03 AM
alex-t requested review of this revision.Dec 16 2021, 9:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2021, 9:03 AM
Herald added a subscriber: wdng. · View Herald Transcript
alex-t edited the summary of this revision. (Show Details)Dec 16 2021, 9:05 AM
foad added inline comments.Dec 16 2021, 9:23 AM
llvm/lib/Target/AMDGPU/SIInstructions.td
2120

There are already patterns on the definitions of S_NOT_* in SOPInstructions.td. Can you update those, instead of adding new standalone patterns?

foad added a reviewer: foad.Dec 16 2021, 9:23 AM
rampitec added inline comments.Dec 16 2021, 11:13 AM
llvm/lib/Target/AMDGPU/SIInstructions.td
2120

+1.

alex-t added inline comments.Dec 17 2021, 4:59 AM
llvm/lib/Target/AMDGPU/SIInstructions.td
2120

The pattern in SOPInstructions.td works with the explicit "not" PatFrag. What if there is no "not" but the "xor src, -1" that was produced by the earlier DAG transformations?
Are you quite sure that this scenario never happens?

foad added inline comments.Dec 17 2021, 6:33 AM
llvm/lib/Target/AMDGPU/SIInstructions.td
2120

'not' is not a separate DAG node, it is just a named pattern that matches an xor with -1.

alex-t added inline comments.Dec 17 2021, 7:19 AM
llvm/lib/Target/AMDGPU/SIInstructions.td
2120

Ah... yes. :) "not" is a PatFrag so it is always considered as "not" during selection.

alex-t updated this revision to Diff 395127.Dec 17 2021, 7:23 AM

Uniform XOR src, -1 pattern removed and existing S_NOT_B32/64 patterns equipped with the divergence predicates

alex-t marked 3 inline comments as done.Dec 17 2021, 7:24 AM
foad accepted this revision.Dec 17 2021, 7:41 AM

LGTM but maybe wait a bit in case @rampitec has any further comments.

This revision is now accepted and ready to land.Dec 17 2021, 7:41 AM
This revision was landed with ongoing or failed builds.Dec 20 2021, 3:40 AM
This revision was automatically updated to reflect the committed changes.