summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2017-06-05 22:58:57 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2017-06-05 22:58:57 +0000
commit9e5b5053d1b9d6ea4a1e2c7e7c59e637ed70b061 (patch)
treed2c546e1ba7f01f34f77f144ee3a0f0062ae77fc
parent4d94e994467405321f67339fbb3154e8bbc0b4a0 (diff)
downloadbcm5719-llvm-9e5b5053d1b9d6ea4a1e2c7e7c59e637ed70b061.tar.gz
bcm5719-llvm-9e5b5053d1b9d6ea4a1e2c7e7c59e637ed70b061.zip
RenameIndependentSubregs: Fix handling of undef tied operands
If a tied source operand was undef, it would be replaced but not update the other tied operand, which would end up using different virtual registers. llvm-svn: 304747
-rw-r--r--llvm/lib/CodeGen/RenameIndependentSubregs.cpp5
-rw-r--r--llvm/test/CodeGen/AMDGPU/rename-independent-subregs-invalid-mac-operands.mir69
2 files changed, 74 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/RenameIndependentSubregs.cpp b/llvm/lib/CodeGen/RenameIndependentSubregs.cpp
index cc32e43968b..6923716e10c 100644
--- a/llvm/lib/CodeGen/RenameIndependentSubregs.cpp
+++ b/llvm/lib/CodeGen/RenameIndependentSubregs.cpp
@@ -243,6 +243,11 @@ void RenameIndependentSubregs::rewriteOperands(const IntEqClasses &Classes,
unsigned VReg = Intervals[ID]->reg;
MO.setReg(VReg);
+ if (MO.isTied()) {
+ /// Undef use operands are not tracked in the equivalence class but need
+ /// to be update if they are tied.
+ MO.getParent()->substituteRegister(Reg, VReg, 0, TRI);
+ }
}
// TODO: We could attempt to recompute new register classes while visiting
// the operands: Some of the split register may be fine with less constraint
diff --git a/llvm/test/CodeGen/AMDGPU/rename-independent-subregs-invalid-mac-operands.mir b/llvm/test/CodeGen/AMDGPU/rename-independent-subregs-invalid-mac-operands.mir
new file mode 100644
index 00000000000..1a0d68d81f9
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/rename-independent-subregs-invalid-mac-operands.mir
@@ -0,0 +1,69 @@
+# RUN: llc -march=amdgcn -verify-machineinstrs -run-pass=simple-register-coalescing,rename-independent-subregs -o - %s | FileCheck -check-prefix=GCN %s
+---
+
+# GCN-LABEL: name: mac_invalid_operands
+# GCN: undef %18.sub0 = V_MAC_F32_e32 undef %3, undef %9, undef %18.sub0, implicit %exec
+
+name: mac_invalid_operands
+alignment: 0
+exposesReturnsTwice: false
+legalized: false
+regBankSelected: false
+selected: false
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: vreg_128 }
+ - { id: 1, class: vreg_128 }
+ - { id: 2, class: sgpr_64 }
+ - { id: 3, class: vgpr_32 }
+ - { id: 4, class: vgpr_32 }
+ - { id: 5, class: vgpr_32 }
+ - { id: 6, class: vgpr_32 }
+ - { id: 7, class: sreg_64 }
+ - { id: 8, class: vgpr_32 }
+ - { id: 9, class: vgpr_32 }
+ - { id: 10, class: vreg_64 }
+ - { id: 11, class: vreg_64 }
+ - { id: 12, class: vreg_128 }
+ - { id: 13, class: vreg_128 }
+ - { id: 14, class: vgpr_32 }
+ - { id: 15, class: vreg_64 }
+ - { id: 16, class: vgpr_32 }
+ - { id: 17, class: vreg_128 }
+body: |
+ bb.0:
+ successors: %bb.2, %bb.1
+
+ %7 = V_CMP_NEQ_F32_e64 0, 0, 0, undef %3, 0, 0, implicit %exec
+ %vcc = COPY killed %7
+ S_CBRANCH_VCCZ %bb.2, implicit killed %vcc
+
+ bb.1:
+ successors: %bb.3
+
+ %4 = V_ADD_F32_e32 undef %6, undef %5, implicit %exec
+ undef %12.sub0 = COPY killed %4
+ %17 = COPY killed %12
+ S_BRANCH %bb.3
+
+ bb.2:
+ successors: %bb.3
+
+ %8 = V_MAC_F32_e32 undef %3, undef %9, undef %8, implicit %exec
+ undef %13.sub0 = COPY %8
+ %13.sub1 = COPY %8
+ %13.sub2 = COPY killed %8
+ %0 = COPY killed %13
+ %17 = COPY killed %0
+
+ bb.3:
+ %1 = COPY killed %17
+ FLAT_STORE_DWORD undef %10, %1.sub2, 0, 0, implicit %exec, implicit %flat_scr
+ %14 = COPY %1.sub1
+ %16 = COPY killed %1.sub0
+ undef %15.sub0 = COPY killed %16
+ %15.sub1 = COPY killed %14
+ FLAT_STORE_DWORDX2 undef %11, killed %15, 0, 0, implicit %exec, implicit %flat_scr
+ S_ENDPGM
+
+...
OpenPOWER on IntegriCloud