[llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Jan 18 23:08:57 PST 2005
Changes in directory llvm/lib/CodeGen:
TwoAddressInstructionPass.cpp updated: 1.28 -> 1.29
---
Log message:
Use the TargetInstrInfo::commuteInstruction method to commute instructions
instead of doing it manually.
---
Diffs of the changes: (+17 -6)
Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.28 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.29
--- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.28 Sat Jan 1 20:34:12 2005
+++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Wed Jan 19 01:08:42 2005
@@ -141,12 +141,23 @@
unsigned regC = mi->getOperand(2).getReg();
if (LV.KillsRegister(mi, regC)) {
DEBUG(std::cerr << "2addr: COMMUTING : " << *mi);
- mi->SetMachineOperandReg(2, regB);
- mi->SetMachineOperandReg(1, regC);
- DEBUG(std::cerr << "2addr: COMMUTED TO: " << *mi);
- ++NumCommuted;
- regB = regC;
- goto InstructionRearranged;
+ MachineInstr *NewMI = TII.commuteInstruction(mi);
+ if (NewMI == 0) {
+ DEBUG(std::cerr << "2addr: COMMUTING FAILED!\n");
+ } else {
+ DEBUG(std::cerr << "2addr: COMMUTED TO: " << *NewMI);
+ // If the instruction changed to commute it, update livevar.
+ if (NewMI != mi) {
+ LV.instructionChanged(mi, NewMI); // Update live variables
+ mbbi->insert(mi, NewMI); // Insert the new inst
+ mbbi->erase(mi); // Nuke the old inst.
+ mi = NewMI;
+ }
+
+ ++NumCommuted;
+ regB = regC;
+ goto InstructionRearranged;
+ }
}
}
// If this instruction is potentially convertible to a true
More information about the llvm-commits
mailing list