[PATCH] D80434: [AMDGPU] Reject moving PHI to VALU if the only VGPR input originated from move immediate
Alexander via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 22 05:51:24 PDT 2020
alex-t created this revision.
alex-t added a reviewer: rampitec.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl, arsenm.
Herald added a project: LLVM.
alex-t updated this revision to Diff 265715.
alex-t added a comment.
test added
PHIs result register class is set to VGPR or SGPR depending on the cross block value divergence.
In some cases uniform PHI need to be converted to return VGPR to prevent the oddnumber of moves values from VGPR to SGPR and back.
PHI should certainly return VGPR if it has at least one VGPR input. This change adds the exception.
We don't want to convert uniform PHI to VGPRs in case the only VGPR input is a VGPR to SGPR COPY and definition od the
source VGPR in this COPY is move immediate.
bb.0:
%0:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
%2:sreg_32 = .....
bb.1:
%3:sreg_32 = PHI %1, %bb.3, %2, %bb.1
S_BRANCH %bb.3
bb.3:
%1:sreg_32 = COPY %0
S_BRANCH %bb.2
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80434
Files:
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
llvm/test/CodeGen/AMDGPU/phi-vgpr-input-moveimm.mir
Index: llvm/test/CodeGen/AMDGPU/phi-vgpr-input-moveimm.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/phi-vgpr-input-moveimm.mir
@@ -0,0 +1,32 @@
+# RUN: llc -march=amdgcn -verify-machineinstrs -run-pass=si-fix-sgpr-copies -o - %s | FileCheck -check-prefix=GCN %s
+---
+# GCN_LABEL: bb.2:
+# GCN-NOT: %{{[0-9]+}}:vgpr_32 = PHI %{{[0-9]+}}, %bb.3, %{{[0-9]+}}, %bb.1
+# GCN: %{{[0-9]+}}:sreg_32 = PHI %{{[0-9]+}}, %bb.3, %{{[0-9]+}}, %bb.1
+
+name: phi_moveimm_input
+tracksRegLiveness: true
+body: |
+ bb.0:
+ successors: %bb.1
+ liveins: $sgpr0, $sgpr1
+
+ %0:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
+
+ %4:sreg_32 = COPY $sgpr0
+ %5:sreg_32 = COPY $sgpr1
+
+ bb.1:
+
+ successors: %bb.2
+ %2:sreg_32 = S_ADD_U32 %4, %5, implicit-def $scc
+ S_BRANCH %bb.2
+ bb.2:
+ successors: %bb.3
+ %3:sreg_32 = PHI %1, %bb.3, %2, %bb.1
+ S_BRANCH %bb.3
+ bb.3:
+ successors: %bb.2
+ %1:sreg_32 = COPY %0
+ S_BRANCH %bb.2
+...
Index: llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
+++ llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
@@ -835,8 +835,12 @@
}
else if (Def->isCopy() &&
TRI->isVectorRegister(*MRI, Def->getOperand(1).getReg())) {
- hasVGPRInput = true;
- break;
+ Register SrcReg = Def->getOperand(1).getReg();
+ MachineInstr *SrcDef = MRI->getVRegDef(SrcReg);
+ if (!SrcDef->isMoveImmediate()) {
+ hasVGPRInput = true;
+ break;
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80434.265715.patch
Type: text/x-patch
Size: 1698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200522/e35b1283/attachment-0001.bin>
More information about the llvm-commits
mailing list