performance: cache the dereferenced use_iterator
authorGabor Greif <ggreif@gmail.com>
Wed, 14 Apr 2010 16:13:56 +0000 (16:13 +0000)
committerGabor Greif <ggreif@gmail.com>
Wed, 14 Apr 2010 16:13:56 +0000 (16:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101250 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LICM.cpp

index d7ace342fcba272622a54632e9e8de2e62b1ae42..73473952912ee59b2aee279b74d9ec43578f166d 100644 (file)
@@ -683,16 +683,18 @@ void LICM::PromoteValuesInLoop() {
       // to LI as we are loading or storing.  Since we know that the value is
       // stored in this loop, this will always succeed.
       for (Value::use_iterator UI = Ptr->use_begin(), E = Ptr->use_end();
-           UI != E; ++UI)
-        if (LoadInst *LI = dyn_cast<LoadInst>(*UI)) {
+           UI != E; ++UI) {
+        User *U = *UI;
+        if (LoadInst *LI = dyn_cast<LoadInst>(U)) {
           LoadValue = LI;
           break;
-        } else if (StoreInst *SI = dyn_cast<StoreInst>(*UI)) {
+        } else if (StoreInst *SI = dyn_cast<StoreInst>(U)) {
           if (SI->getOperand(1) == Ptr) {
             LoadValue = SI->getOperand(0);
             break;
           }
         }
+      }
       assert(LoadValue && "No store through the pointer found!");
       PointerValueNumbers.push_back(LoadValue);  // Remember this for later.
     }