From 79c50d96c9ff3f9eb24a1db130e95c1c1672319f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 28 Apr 2006 04:43:18 +0000 Subject: [PATCH] Mapping of physregs can make it so that the designated and input physregs are the same. In this case, don't emit a noop copy. llvm-svn: 28008 --- llvm/lib/CodeGen/VirtRegMap.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp index b30c61c8382a..f0dd40d1e16a 100644 --- a/llvm/lib/CodeGen/VirtRegMap.cpp +++ b/llvm/lib/CodeGen/VirtRegMap.cpp @@ -611,6 +611,19 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM) { DesignatedReg = ReusedOperands.GetRegForReload(DesignatedReg, &MI, Spills, MaybeDeadStores); + // If the mapped designated register is actually the physreg we have + // incoming, we don't need to inserted a dead copy. + if (DesignatedReg == PhysReg) { + // If this stack slot value is already available, reuse it! + DEBUG(std::cerr << "Reusing SS#" << StackSlot << " from physreg " + << MRI->getName(PhysReg) << " for vreg" + << VirtReg + << " instead of reloading into same physreg.\n"); + MI.SetMachineOperandReg(i, PhysReg); + ++NumReused; + continue; + } + const TargetRegisterClass* RC = MBB.getParent()->getSSARegMap()->getRegClass(VirtReg);