From: Chris Lattner Date: Fri, 1 Dec 2006 19:50:54 +0000 (+0000) Subject: These should be rewritten to fold without using the 'Rules' mechanism, but X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=9dec3a2c0ca8d59e50ffbf1c97b171c7d5f2d6ec;p=oota-llvm.git 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 --- 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