Mapping of physregs can make it so that the designated and input physregs are
authorChris Lattner <sabre@nondot.org>
Fri, 28 Apr 2006 04:43:18 +0000 (04:43 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 28 Apr 2006 04:43:18 +0000 (04:43 +0000)
the same.  In this case, don't emit a noop copy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28008 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/VirtRegMap.cpp

index b30c61c8382a961aea62233ea8ae95fb62c8cf4a..f0dd40d1e16aab15ca365f3edcc919c8fbb3a213 100644 (file)
@@ -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);