This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Rework SCC copy
ClosedPublic

Authored by piotr on Jun 23 2020, 5:01 AM.

Details

Reviewers
arsenm
Summary

In D81925, S_CMP_LG_U64 was used for copies to SCC,
which is only safe for hw with hasScalarCompareEq64.
Rework this part to use the lower part for the comparison
and use S_CMP_LG_U32 instead.

Additionally, remove pattern for selects with 64-bit
inputs, which are rare, because handling them properly
requires more thought.

Depends on D81925.

Diff Detail

Event Timeline

piotr created this revision.Jun 23 2020, 5:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2020, 5:01 AM
arsenm added inline comments.Jun 23 2020, 6:40 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
674–675

I think you should never end up in this situation to begin with. Maybe this should be a verifier error instead?

piotr added inline comments.Jun 23 2020, 8:09 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
674–675

This comes directly from the isel, so I guess is one of the peculiarities of flag registers handling.

Instruction selection ends

...

    t89: i1 = V_CMP_LT_U64_e64 t103, t144 
  t131: ch,glue = CopyToReg t0, Register:i1 $scc, t89
t86: i32 = S_CSELECT_B32 t55, t141, t131:1

...

  • MachineFunction at end of ISel ***

...

%46:sreg_64 = V_CMP_LT_U64_e64 %27:sreg_64, %47:vreg_64, implicit $exec
$scc = COPY %46:sreg_64
%48:sreg_32 = S_CSELECT_B32 killed %44:sreg_32, %42:sreg_32, implicit $scc

...

arsenm added inline comments.Jun 23 2020, 9:56 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
674–675

I think this needs a comment that this is only to tolerate SelectionDAG nonsense. When we finally delete it, we should remove this.
Can you also add a fixme that we should be using S_BITCMP0_B32 instead and only consider the 0th bit?

piotr updated this revision to Diff 272928.Jun 24 2020, 12:54 AM

Reworded comment, added a TODO.

arsenm accepted this revision.Jun 24 2020, 7:07 AM
This revision is now accepted and ready to land.Jun 24 2020, 7:07 AM
piotr closed this revision.Jun 25 2020, 2:06 AM