Don't call lookupNumber more than we have to.
[oota-llvm.git] / lib / Transforms / Scalar / GVN.cpp
index 86a8238ee425a5df8a19cffdb486262c4f06e6e9..18a9661684f35c72d7e27c2938979d4c3bc2a80e 100644 (file)
@@ -1267,11 +1267,14 @@ bool GVN::performPRE(Function& F) {
         Value* op = BI->getOperand(i);
         if (isa<Argument>(op) || isa<Constant>(op) || isa<GlobalValue>(op))
           PREInstr->setOperand(i, op);
-        else if (!lookupNumber(PREPred, VN.lookup(op))) {
-          success = false;
-          break;
-        } else
-          PREInstr->setOperand(i, lookupNumber(PREPred, VN.lookup(op)));
+        else {
+          Value* V = lookupNumber(PREPred, VN.lookup(op));
+          if (!V) {
+            success = false;
+            break;
+          } else
+            PREInstr->setOperand(i, V);
+        }
       }
       
       // Fail out if we encounter an operand that is not available in