aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 48d84e5ac5..49bdca2c5e 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<ConstantInt>(V))
V = ConstantInt::get(SrcTy->getSignedVersion(),
cast<ConstantIntegral>(V)->getSExtValue());
+ else if (const ConstantBool *CB = dyn_cast<ConstantBool>(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