Skip to content

Commit 16ac7ac

Browse files
committed
Another fix (dead destination reg)
1 parent 875e232 commit 16ac7ac

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/lib/CodeGen/RegisterCoalescer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,7 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
19301930
Reads = DstInt->liveAt(LIS->getInstructionIndex(*UseMI));
19311931

19321932
bool FullDef = true;
1933+
bool DeadDef = false;
19331934

19341935
// Replace SrcReg with DstReg in all UseMI operands.
19351936
for (unsigned Op : Ops) {
@@ -1941,6 +1942,7 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
19411942
if (SubIdx && MO.isDef()) {
19421943
MO.setIsUndef(!Reads);
19431944
FullDef = false;
1945+
DeadDef = MO.isDead();
19441946
}
19451947

19461948
// A subreg use of a partially undef (super) register may be a complete
@@ -1974,7 +1976,7 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
19741976
MO.substVirtReg(DstReg, SubIdx, *TRI);
19751977
}
19761978

1977-
if (IsSubregToReg && !FullDef) {
1979+
if (IsSubregToReg && !FullDef && !DeadDef) {
19781980
// If the coalesed instruction doesn't fully define the register, we need
19791981
// to preserve the original super register liveness for SUBREG_TO_REG.
19801982
//

llvm/test/CodeGen/X86/coalescer-subreg-to-reg-implicit-def-regression.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ body: |
2727
; CHECK-NEXT: MOVAPSmr $noreg, 1, $noreg, 16, $noreg, [[V_SET0_]]
2828
; CHECK-NEXT: MOVAPSmr $noreg, 1, $noreg, 0, $noreg, [[V_SET0_]]
2929
; CHECK-NEXT: dead [[DEF1:%[0-9]+]]:gr32 = IMPLICIT_DEF
30-
; CHECK-NEXT: dead [[DEF:%[0-9]+]].sub_32bit:gr64_with_sub_8bit = OR32ri [[DEF]].sub_32bit, 1, implicit-def $eflags, implicit-def [[DEF]]
30+
; CHECK-NEXT: dead [[DEF:%[0-9]+]].sub_32bit:gr64_with_sub_8bit = OR32ri [[DEF]].sub_32bit, 1, implicit-def $eflags
3131
; CHECK-NEXT: JMP_1 %bb.3
3232
; CHECK-NEXT: {{ $}}
3333
; CHECK-NEXT: bb.3:

0 commit comments

Comments
 (0)