[PATCH] D51346: AMDGPU: Don't delete instructions if S_ENDPGM has implicit uses
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 28 04:53:17 PDT 2018
arsenm created this revision.
arsenm added a reviewer: rampitec.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl.
This can leave behind the uses with the defs removed.
Since this should only really happen in tests, it's not worth the
effort of trying to handle this.
https://reviews.llvm.org/D51346
Files:
lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
test/CodeGen/AMDGPU/endpgm-dce.mir
Index: test/CodeGen/AMDGPU/endpgm-dce.mir
===================================================================
--- test/CodeGen/AMDGPU/endpgm-dce.mir
+++ test/CodeGen/AMDGPU/endpgm-dce.mir
@@ -295,3 +295,20 @@
bb.2:
S_ENDPGM
...
+
+# GCN-LABEL: name: implicit_use_on_s_endpgm
+# GCN: V_ADD_I32
+# GCN: COPY
+# GCN: V_ADDC_U32
+# GCN: S_ENDPGM implicit %3
+name: implicit_use_on_s_endpgm
+tracksRegLiveness: true
+
+body: |
+ bb.0:
+ dead %0:vgpr_32 = V_ADD_I32_e32 12345, undef %1:vgpr_32, implicit-def $vcc, implicit $exec
+ %2:sreg_64_xexec = COPY $vcc
+ %3:vgpr_32, dead %4:sreg_64_xexec = V_ADDC_U32_e64 undef %5:vgpr_32, undef %6:vgpr_32, %2, implicit $exec
+ S_ENDPGM implicit %3
+
+...
Index: lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
===================================================================
--- lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
+++ lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
@@ -119,7 +119,14 @@
// Try to remove unneeded instructions before s_endpgm.
if (MBB.succ_empty()) {
- if (MBB.empty() || MBB.back().getOpcode() != AMDGPU::S_ENDPGM)
+ if (MBB.empty())
+ continue;
+
+ // Skip this if the endpgm has any implicit uses, otherwise we would need
+ // to be careful to update / remove them.
+ MachineInstr &Term = MBB.back();
+ if (Term.getOpcode() != AMDGPU::S_ENDPGM ||
+ Term.getNumOperands() != 0)
continue;
SmallVector<MachineBasicBlock*, 4> Blocks({&MBB});
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51346.162828.patch
Type: text/x-patch
Size: 1523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180828/e3cb27a1/attachment.bin>
More information about the llvm-commits
mailing list