Use CloneMachineInstr to make a new MI in commuteInstruction to make the code tolerant of instructions with more than two input operands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163000 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2012-08-31 16:30:05 +00:00
parent bf4043768c
commit 89b2ff0b5c

View File

@ -99,17 +99,8 @@ MachineInstr *TargetInstrInfoImpl::commuteInstruction(MachineInstr *MI,
if (NewMI) {
// Create a new instruction.
bool Reg0IsDead = HasDef ? MI->getOperand(0).isDead() : false;
MachineFunction &MF = *MI->getParent()->getParent();
if (HasDef)
return BuildMI(MF, MI->getDebugLoc(), MI->getDesc())
.addReg(Reg0, RegState::Define | getDeadRegState(Reg0IsDead), SubReg0)
.addReg(Reg2, getKillRegState(Reg2IsKill), SubReg2)
.addReg(Reg1, getKillRegState(Reg1IsKill), SubReg1);
else
return BuildMI(MF, MI->getDebugLoc(), MI->getDesc())
.addReg(Reg2, getKillRegState(Reg2IsKill), SubReg2)
.addReg(Reg1, getKillRegState(Reg1IsKill), SubReg1);
MI = MF.CloneMachineInstr(MI);
}
if (HasDef) {