Skip to content

Commit d729070

Browse files
committed
REG_SEQUENCE expansion to COPY instructions wasn't taking account of sub register indices on the source registers. No simple test case
llvm-svn: 154051
1 parent d1717c1 commit d729070

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/CodeGen/TwoAddressInstructionPass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,7 @@ bool TwoAddressInstructionPass::EliminateRegSequences() {
18321832
SmallSet<unsigned, 4> Seen;
18331833
for (unsigned i = 1, e = MI->getNumOperands(); i < e; i += 2) {
18341834
unsigned SrcReg = MI->getOperand(i).getReg();
1835+
unsigned SrcSubIdx = MI->getOperand(i).getSubReg();
18351836
unsigned SubIdx = MI->getOperand(i+1).getImm();
18361837
// DefMI of NULL means the value does not have a vreg in this block
18371838
// i.e., its a physical register or a subreg.
@@ -1887,7 +1888,7 @@ bool TwoAddressInstructionPass::EliminateRegSequences() {
18871888
MachineInstr *CopyMI = BuildMI(*MI->getParent(), InsertLoc,
18881889
MI->getDebugLoc(), TII->get(TargetOpcode::COPY))
18891890
.addReg(DstReg, RegState::Define, SubIdx)
1890-
.addReg(SrcReg, getKillRegState(isKill));
1891+
.addReg(SrcReg, getKillRegState(isKill), SrcSubIdx);
18911892
MI->getOperand(i).setReg(0);
18921893
if (LV && isKill && !TargetRegisterInfo::isPhysicalRegister(SrcReg))
18931894
LV->replaceKillInstruction(SrcReg, MI, CopyMI);

0 commit comments

Comments
 (0)