Enhance a couple places where we were doing constant folding of instructions,
[oota-llvm.git] / lib / Transforms / InstCombine / InstCombineSelect.cpp
index ffca57b7735df4dc0dca2d210d3b0fff09b212cc..ae42d526ae71a22923ec468330304c8136e55a48 100644 (file)
@@ -324,9 +324,14 @@ static Value *SimplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
     }
 
     // All operands were constants, fold it.
-    if (ConstOps.size() == I->getNumOperands())
+    if (ConstOps.size() == I->getNumOperands()) {
+      if (LoadInst *LI = dyn_cast<LoadInst>(I))
+        if (!LI->isVolatile())
+          return ConstantFoldLoadFromConstPtr(ConstOps[0], TD);
+
       return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
                                       ConstOps, TD);
+    }
   }
 
   return 0;