[llvm-commits] [llvm] r40840 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Chris Lattner sabre at nondot.org
Sun Aug 5 01:47:58 PDT 2007


Author: lattner
Date: Sun Aug  5 03:47:58 2007
New Revision: 40840

URL: http://llvm.org/viewvc/llvm-project?rev=40840&view=rev
Log:
at the end of instcombine, explicitly clear WorklistMap.
This shrinks it down to something small.  On the testcase
from PR1432, this speeds up instcombine from 0.7959s to 0.5000s,
(59%)

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

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=40840&r1=40839&r2=40840&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun Aug  5 03:47:58 2007
@@ -870,11 +870,10 @@
 // could have the specified known zero and known one bits, returning them in
 // min/max.
 static void ComputeUnsignedMinMaxValuesFromKnownBits(const Type *Ty,
-                                                     const APInt& KnownZero,
-                                                     const APInt& KnownOne,
-                                                     APInt& Min,
-                                                     APInt& Max) {
-  uint32_t BitWidth = cast<IntegerType>(Ty)->getBitWidth();
+                                                     const APInt &KnownZero,
+                                                     const APInt &KnownOne,
+                                                     APInt &Min, APInt &Max) {
+  uint32_t BitWidth = cast<IntegerType>(Ty)->getBitWidth(); BitWidth = BitWidth;
   assert(KnownZero.getBitWidth() == BitWidth && 
          KnownOne.getBitWidth() == BitWidth &&
          Min.getBitWidth() == BitWidth && Max.getBitWidth() &&
@@ -1885,7 +1884,7 @@
   if (I.getNumOperands() == 2) {
     Constant *C = cast<Constant>(I.getOperand(1));
     for (unsigned i = 0; i != NumPHIValues; ++i) {
-      Value *InV;
+      Value *InV = 0;
       if (Constant *InC = dyn_cast<Constant>(PN->getIncomingValue(i))) {
         if (CmpInst *CI = dyn_cast<CmpInst>(&I))
           InV = ConstantExpr::getCompare(CI->getPredicate(), InC, C);
@@ -4095,7 +4094,7 @@
 
   // xor X, X = 0, even if X is nested in a sequence of Xor's.
   if (Instruction *Result = AssociativeOpt(I, XorSelf(Op1))) {
-    assert(Result == &I && "AssociativeOpt didn't work?");
+    assert(Result == &I && "AssociativeOpt didn't work?"); Result=Result;
     return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
   }
   
@@ -10051,6 +10050,9 @@
   }
 
   assert(WorklistMap.empty() && "Worklist empty, but map not?");
+    
+  // Do an explicit clear, this shrinks the map if needed.
+  WorklistMap.clear();
   return Changed;
 }
 





More information about the llvm-commits mailing list