aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-12-01 19:50:54 +0000
committerChris Lattner <sabre@nondot.org>2006-12-01 19:50:54 +0000
commit9dec3a2c0ca8d59e50ffbf1c97b171c7d5f2d6ec (patch)
treea6aaa5248e9780437ffdef442ec756eef4a6b40d
parent63edf03fe51f8fe24230dd5891e4b8f252378a3d (diff)
These should be rewritten to fold without using the 'Rules' mechanism, but
until this happens at least make sext from bool and sitofp from bool do the right thing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32087 91177308-0d34-0410-b5e6-96231b3b80d8
-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