[llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Feb 2 18:03:11 PST 2006



Changes in directory llvm/lib/CodeGen:

VirtRegMap.cpp updated: 1.47 -> 1.48
---
Log message:

Add code that checks for noop copies, which triggers when either:
1. a target doesn't know how to fold load/stores into copies, or
2. the spiller rewrites the input to a copy to the same register as the dest
   instead of to the reloaded reg.

This will be moved/improved in the near future, but allows elimination of
some ancient x86 hacks.  This eliminates 92 copies from SMG2000 on X86 and
163 copies from 252.eon.



---
Diffs of the changes:  (+13 -0)

 VirtRegMap.cpp |   13 +++++++++++++
 1 files changed, 13 insertions(+)


Index: llvm/lib/CodeGen/VirtRegMap.cpp
diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.47 llvm/lib/CodeGen/VirtRegMap.cpp:1.48
--- llvm/lib/CodeGen/VirtRegMap.cpp:1.47	Thu Feb  2 18:36:31 2006
+++ llvm/lib/CodeGen/VirtRegMap.cpp	Thu Feb  2 20:02:59 2006
@@ -38,6 +38,7 @@
   Statistic<> NumLoads ("spiller", "Number of loads added");
   Statistic<> NumReused("spiller", "Number of values reused");
   Statistic<> NumDSE   ("spiller", "Number of dead stores elided");
+  Statistic<> NumDCE   ("spiller", "Number of copies elided");
 
   enum SpillerName { simple, local };
 
@@ -658,6 +659,18 @@
         }
       }
     }
+     
+    // Okay, the instruction has been completely processed, input and output 
+    // registers have been added.  As a final sanity check, make sure this is
+    // not a noop-copy.  If it is, nuke it.
+    {
+      unsigned Src, Dst;
+      if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) {
+        ++NumDCE;
+        DEBUG(std::cerr << "Removing now-noop copy: " << MI);
+        MBB.erase(&MI);
+      }
+    }
   ProcessNextInst:
     MII = NextMII;
   }






More information about the llvm-commits mailing list