[AMDGPU] Fix SGPR fixing through SCC chaining
Summary:
- During the fixing of SGPR copying from VGPR, ensure users of SCC is
properly propagated, i.e.
* only propagate through live def of SCC,
* skip the SCC-def inst itself, and
* stop the propagation on the other SCC-def inst after checking its
SCC-use first.
Subscribers: arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59362
llvm-svn: 356258
2019-03-15 20:42:21 +08:00
|
|
|
# RUN: llc -march=amdgcn -run-pass=si-fix-sgpr-copies -o - %s | FileCheck --check-prefix=GCN %s
|
|
|
|
|
|
|
|
# GCN-LABEL: name: fix-sgpr-copies
|
|
|
|
# GCN: V_ADD_I32_e32
|
|
|
|
# GCN: V_ADDC_U32_e32
|
|
|
|
---
|
|
|
|
name: fix-sgpr-copies
|
|
|
|
body: |
|
|
|
|
bb.0:
|
|
|
|
%0:vgpr_32 = IMPLICIT_DEF
|
|
|
|
%1:sreg_32 = IMPLICIT_DEF
|
|
|
|
%2:sreg_32 = IMPLICIT_DEF
|
|
|
|
%3:sreg_32 = IMPLICIT_DEF
|
|
|
|
%4:vgpr_32 = V_CVT_U32_F32_e64 0, %0:vgpr_32, 0, 0, implicit $exec
|
|
|
|
%5:sreg_32 = COPY %4:vgpr_32
|
|
|
|
%6:sreg_32 = S_ADD_I32 %2:sreg_32, %5:sreg_32, implicit-def $scc
|
|
|
|
%7:sreg_32 = S_ADDC_U32 %3:sreg_32, %1:sreg_32, implicit-def $scc, implicit $scc
|
|
|
|
...
|
[AMDGPU] Fix the mis-handling of `vreg_1` copied from scalar register.
Summary:
- Don't treat the use of a scalar register as `vreg_1` an VGPR usage.
Otherwise, that promotes that scalar register into vector one, which
breaks the assumption that scalar register holds the lane mask.
- The issue is triggered in a complicated case, where if the uses of
that (lane mask) scalar register is legalized firstly before its
definition, e.g., due to the mismatch block placement and its
topological order or loop. In that cases, the legalization of PHI
introduces the use of that scalar register as `vreg_1`.
Reviewers: rampitec, nhaehnle, arsenm, alex-t
Subscribers: kzhuravl, jvesely, wdng, dstuttard, tpr, t-tye, hiraditya, llvm-commits, yaxunl
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62492
llvm-svn: 361847
2019-05-29 00:29:39 +08:00
|
|
|
|
|
|
|
# Test to ensure i1 phi copies from scalar registers through another phi won't
|
|
|
|
# be promoted into vector ones.
|
|
|
|
# GCN-LABEL: name: fix-sgpr-i1-phi-copies
|
|
|
|
# GCN: .8:
|
|
|
|
# GCN-NOT: vreg_64 = PHI
|
|
|
|
---
|
|
|
|
name: fix-sgpr-i1-phi-copies
|
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.9:
|
|
|
|
S_BRANCH %bb.0
|
|
|
|
|
|
|
|
bb.4:
|
|
|
|
S_CBRANCH_SCC1 %bb.6, implicit undef $scc
|
|
|
|
|
|
|
|
bb.5:
|
|
|
|
%3:vreg_1 = IMPLICIT_DEF
|
|
|
|
|
|
|
|
bb.6:
|
|
|
|
%4:vreg_1 = PHI %2:sreg_64, %bb.4, %3:vreg_1, %bb.5
|
|
|
|
|
|
|
|
bb.7:
|
|
|
|
%5:vreg_1 = PHI %2:sreg_64, %bb.3, %4:vreg_1, %bb.6
|
|
|
|
S_BRANCH %bb.8
|
|
|
|
|
|
|
|
bb.0:
|
|
|
|
S_CBRANCH_SCC1 %bb.2, implicit undef $scc
|
|
|
|
|
|
|
|
bb.1:
|
|
|
|
%0:sreg_64 = S_MOV_B64 0
|
|
|
|
S_BRANCH %bb.3
|
|
|
|
|
|
|
|
bb.2:
|
|
|
|
%1:sreg_64 = S_MOV_B64 -1
|
|
|
|
S_BRANCH %bb.3
|
|
|
|
|
|
|
|
bb.3:
|
|
|
|
%2:sreg_64 = PHI %0:sreg_64, %bb.1, %1:sreg_64, %bb.2
|
|
|
|
S_CBRANCH_SCC1 %bb.7, implicit undef $scc
|
|
|
|
S_BRANCH %bb.4
|
|
|
|
|
|
|
|
bb.8:
|
|
|
|
...
|
AMDGPU: Fix infinite searches in SIFixSGPRCopies
Summary:
Two conditions could lead to infinite loops when processing PHI nodes in
SIFixSGPRCopies.
The first condition involves a REG_SEQUENCE that uses registers defined by both
a PHI and a COPY.
The second condition arises when a physical register is copied to a virtual
register which is then used in a PHI node. If the same virtual register is
copied to the same physical register, the result is an endless loop.
%0:sgpr_64 = COPY $sgpr0_sgpr1
%2 = PHI %0, %bb.0, %1, %bb.1
$sgpr0_sgpr1 = COPY %0
Reviewers: alex-t, rampitec, arsenm
Reviewed By: rampitec
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68970
llvm-svn: 374944
2019-10-16 03:59:45 +08:00
|
|
|
|
|
|
|
# Avoid infinite loop in SIInstrInfo::legalizeGenericOperand when checking for ImpDef.
|
|
|
|
# GCN-LABEL: name: legalize-operand-search-each-def-once
|
|
|
|
# GCN-NOT: sreg_64 PHI
|
|
|
|
---
|
|
|
|
name: legalize-operand-search-each-def-once
|
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0:
|
|
|
|
successors: %bb.1, %bb.2
|
|
|
|
liveins: $sgpr0_sgpr1
|
|
|
|
|
|
|
|
%0:sgpr_64 = COPY $sgpr0_sgpr1
|
|
|
|
S_CBRANCH_VCCZ %bb.2, implicit undef $vcc
|
|
|
|
S_BRANCH %bb.1
|
|
|
|
|
|
|
|
bb.1:
|
|
|
|
%1:vreg_64 = IMPLICIT_DEF
|
|
|
|
S_BRANCH %bb.2
|
|
|
|
|
|
|
|
bb.2:
|
|
|
|
%2:sgpr_64 = PHI %0, %bb.0, %1, %bb.1
|
|
|
|
$sgpr0_sgpr1 = COPY %0
|
|
|
|
...
|
|
|
|
|
|
|
|
# A REG_SEQUENCE that uses registers defined by both a PHI and a COPY could
|
|
|
|
# result in an endless search.
|
|
|
|
# GCN-LABEL: name: process-phi-search-each-use-once
|
|
|
|
# GCN-NOT: sreg_32 PHI
|
|
|
|
---
|
|
|
|
name: process-phi-search-each-use-once
|
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0:
|
|
|
|
successors: %bb.1, %bb.2
|
|
|
|
liveins: $vgpr3
|
|
|
|
|
|
|
|
%0:vgpr_32 = COPY $vgpr3
|
|
|
|
S_CBRANCH_VCCZ %bb.2, implicit undef $vcc
|
|
|
|
S_BRANCH %bb.1
|
|
|
|
|
|
|
|
bb.1:
|
|
|
|
%1:sgpr_32 = IMPLICIT_DEF
|
|
|
|
S_BRANCH %bb.2
|
|
|
|
|
|
|
|
bb.2:
|
|
|
|
%2:sgpr_32 = PHI %0, %bb.0, %1, %bb.1
|
|
|
|
%3:vreg_64 = REG_SEQUENCE %2, %subreg.sub0, %0, %subreg.sub1
|
|
|
|
$vgpr3 = COPY %3.sub0
|
|
|
|
...
|