[llvm-commits] [llvm] r108131 - in /llvm/trunk/lib: Transforms/Scalar/TailDuplication.cpp Transforms/Scalar/TailRecursionElimination.cpp VMCore/Instruction.cpp

Gabor Greif ggreif at gmail.com
Mon Jul 12 03:36:48 PDT 2010


Author: ggreif
Date: Mon Jul 12 05:36:48 2010
New Revision: 108131

URL: http://llvm.org/viewvc/llvm-project?rev=108131&view=rev
Log:
cache dereferenced iterators

Modified:
    llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp
    llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
    llvm/trunk/lib/VMCore/Instruction.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp?rev=108131&r1=108130&r2=108131&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp Mon Jul 12 05:36:48 2010
@@ -206,13 +206,14 @@
   // there is only one other pred, get it, otherwise we can't handle it.
   PI = pred_begin(DstBlock); PE = pred_end(DstBlock);
   BasicBlock *DstOtherPred = 0;
-  if (*PI == SrcBlock) {
+  BasicBlock *P = *PI;
+  if (P == SrcBlock) {
     if (++PI == PE) return 0;
-    DstOtherPred = *PI;
+    DstOtherPred = P;
     if (++PI != PE) return 0;
   } else {
-    DstOtherPred = *PI;
-    if (++PI == PE || *PI != SrcBlock || ++PI != PE) return 0;
+    DstOtherPred = P;
+    if (++PI == PE || P != SrcBlock || ++PI != PE) return 0;
   }
 
   // We can handle two situations here: "if then" and "if then else" blocks.  An

Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=108131&r1=108130&r2=108131&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Mon Jul 12 05:36:48 2010
@@ -476,10 +476,11 @@
     // it will not show up as a predecessor.
     for (pred_iterator PI = pred_begin(OldEntry), PE = pred_end(OldEntry);
          PI != PE; ++PI) {
-      if (*PI == &F->getEntryBlock())
-        AccPN->addIncoming(AccumulatorRecursionEliminationInitVal, *PI);
+      BasicBlock *P = *PI;
+      if (P == &F->getEntryBlock())
+        AccPN->addIncoming(AccumulatorRecursionEliminationInitVal, P);
       else
-        AccPN->addIncoming(AccPN, *PI);
+        AccPN->addIncoming(AccPN, P);
     }
 
     // Add an incoming argument for the current block, which is computed by our

Modified: llvm/trunk/lib/VMCore/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=108131&r1=108130&r2=108131&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instruction.cpp (original)
+++ llvm/trunk/lib/VMCore/Instruction.cpp Mon Jul 12 05:36:48 2010
@@ -286,9 +286,10 @@
   for (const_use_iterator UI = use_begin(), E = use_end(); UI != E; ++UI) {
     // PHI nodes uses values in the corresponding predecessor block.  For other
     // instructions, just check to see whether the parent of the use matches up.
-    const PHINode *PN = dyn_cast<PHINode>(*UI);
+    const User *U = *UI;
+    const PHINode *PN = dyn_cast<PHINode>(U);
     if (PN == 0) {
-      if (cast<Instruction>(*UI)->getParent() != BB)
+      if (cast<Instruction>(U)->getParent() != BB)
         return true;
       continue;
     }





More information about the llvm-commits mailing list