eliminate some non-obvious casts. UndefValue isa Constant.
authorChris Lattner <sabre@nondot.org>
Sun, 5 Sep 2010 20:03:09 +0000 (20:03 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 5 Sep 2010 20:03:09 +0000 (20:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113113 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/JumpThreading.cpp

index 104d5aecbdd32810122662e63586df86bd538db5..da0e21699e41f981c0f175f29363ea455cd2e6df 100644 (file)
@@ -443,8 +443,8 @@ ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){
     
       // Try to use constant folding to simplify the binary operator.
       for (unsigned i = 0, e = LHSVals.size(); i != e; ++i) {
-        Constant *V = LHSVals[i].first ? LHSVals[i].first :
-                                 cast<Constant>(UndefValue::get(BO->getType()));
+        Constant *V = LHSVals[i].first;
+        if (V == 0) V = UndefValue::get(BO->getType());
         Constant *Folded = ConstantExpr::get(BO->getOpcode(), V, CI);
         
         PushConstantIntOrUndef(Result, Folded, LHSVals[i].second);
@@ -518,8 +518,8 @@ ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){
         ComputeValueKnownInPredecessors(I->getOperand(0), BB, LHSVals);
         
         for (unsigned i = 0, e = LHSVals.size(); i != e; ++i) {
-          Constant *V = LHSVals[i].first ? LHSVals[i].first :
-                           cast<Constant>(UndefValue::get(CmpConst->getType()));
+          Constant *V = LHSVals[i].first;
+          if (V == 0) V = UndefValue::get(CmpConst->getType());
           Constant *Folded = ConstantExpr::getCompare(Cmp->getPredicate(),
                                                       V, CmpConst);
           PushConstantIntOrUndef(Result, Folded, LHSVals[i].second);