[llvm-commits] [llvm] r126782 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Cameron Zwarich zwarich at apple.com
Tue Mar 1 13:13:54 PST 2011


Author: zwarich
Date: Tue Mar  1 15:13:53 2011
New Revision: 126782

URL: http://llvm.org/viewvc/llvm-project?rev=126782&view=rev
Log:
Stop computing the number of uses twice per value in CodeGenPrepare's sinking of
addressing code. On 403.gcc this almost halves CodeGenPrepare time and reduces
total llc time by 9.5%. Unfortunately, getNumUses() is still the hottest function
in llc.

Modified:
    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=126782&r1=126781&r2=126782&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Mar  1 15:13:53 2011
@@ -701,7 +701,7 @@
   // the addressing mode obtained from the non-PHI roots of the graph
   // are equivalent.
   Value *Consensus = 0;
-  unsigned NumUses = 0;
+  unsigned NumUsesConsensus = 0;
   SmallVector<Instruction*, 16> AddrModeInsts;
   ExtAddrMode AddrMode;
   while (!worklist.empty()) {
@@ -734,9 +734,10 @@
     // such root as representative, select the one with the most uses in order
     // to keep the cost modeling heuristics in AddressingModeMatcher applicable.
     if (!Consensus || NewAddrMode == AddrMode) {
-      if (V->getNumUses() > NumUses) {
+      unsigned NumUses = V->getNumUses();
+      if (NumUses > NumUsesConsensus) {
         Consensus = V;
-        NumUses = V->getNumUses();
+        NumUsesConsensus = NumUses;
         AddrMode = NewAddrMode;
         AddrModeInsts = NewAddrModeInsts;
       }





More information about the llvm-commits mailing list