Changes in directory llvm/lib/CodeGen:
VirtRegMap.cpp updated: 1.69 -> 1.70 --- Log message: Added a check so that if we have two machine instructions in this form MOV R0, R1 MOV R1, R0 the second machine instruction is removed. Added a regression test. --- Diffs of the changes: (+30 -10) VirtRegMap.cpp | 40 ++++++++++++++++++++++++++++++---------- 1 files changed, 30 insertions(+), 10 deletions(-) Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.69 llvm/lib/CodeGen/VirtRegMap.cpp:1.70 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.69 Fri Jul 21 16:15:20 2006 +++ llvm/lib/CodeGen/VirtRegMap.cpp Mon Aug 21 02:33:33 2006 @@ -521,6 +521,7 @@ // Process all of the spilled uses and all non spilled reg references. for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { MachineOperand &MO = MI.getOperand(i); + if (!MO.isRegister() || MO.getReg() == 0) continue; // Ignore non-register operands. @@ -790,16 +791,37 @@ } if (!OpTakenCareOf) { - // Check to see if this is a noop copy. If so, eliminate the - // instruction before considering the dest reg to be changed. unsigned Src, Dst; - if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) { - ++NumDCE; - DEBUG(std::cerr << "Removing now-noop copy: " << MI); - MBB.erase(&MI); - VRM.RemoveFromFoldedVirtMap(&MI); - goto ProcessNextInst; + if (TII->isMoveInstr(MI, Src, Dst)) { + if (Src == Dst) { + // Check to see if this is a noop copy. If so, eliminate + // the instruction before considering the dest reg to be + // changed. + ++NumDCE; + DEBUG(std::cerr << "Removing now-noop copy: " << MI); + MBB.erase(&MI); + VRM.RemoveFromFoldedVirtMap(&MI); + goto ProcessNextInst; + } else if (MII != MBB.begin()) { + // Check to see if this is a sequence of the form: + // mov R0, R1 + // mov R1, R0 + // Eliminate the second move if so. + MachineBasicBlock::iterator PrevMII = MII; --PrevMII; + MachineInstr& PrevMI = *PrevMII; + unsigned PrevSrc, PrevDst; + + if (TII->isMoveInstr(PrevMI, PrevSrc, PrevDst)) + if (PrevSrc == Dst && PrevDst == Src) { + ++NumDCE; + DEBUG(std::cerr << "Removing now-noop copy: " << MI); + MBB.erase(&MI); + VRM.RemoveFromFoldedVirtMap(&MI); + goto ProcessNextInst; + } + } } + Spills.ClobberPhysReg(VirtReg); continue; } @@ -861,8 +883,6 @@ } } - - llvm::Spiller* llvm::createSpiller() { switch (SpillerOpt) { default: assert(0 && "Unreachable!"); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits