diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 48d84e5ac54..49bdca2c5e7 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -890,6 +890,9 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, if (isa(V)) V = ConstantInt::get(SrcTy->getSignedVersion(), cast(V)->getSExtValue()); + else if (const ConstantBool *CB = dyn_cast(V)) + V = ConstantInt::get(Type::SByteTy, CB->getValue() ? -1 : 0); + break; case Instruction::Trunc: // We just handle trunc directly here. The code below doesn't work for