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

lib/Transforms/Scalar/Reg2Mem.cpp

index 7a6eec3d46b4513ee857f2982e61013fbf867857..13222ac22004e27f0c9336322b62ce0c4a9ce3f6 100644 (file)
@@ -46,10 +46,11 @@ namespace {
    bool valueEscapes(const Instruction *Inst) const {
      const BasicBlock *BB = Inst->getParent();
       for (Value::const_use_iterator UI = Inst->use_begin(),E = Inst->use_end();
-           UI != E; ++UI)
-        if (cast<Instruction>(*UI)->getParent() != BB ||
-            isa<PHINode>(*UI))
+           UI != E; ++UI) {
+        const Instruction *I = cast<Instruction>(*UI);
+        if (I->getParent() != BB || isa<PHINode>(I))
           return true;
+      }
       return false;
     }