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
This commit is contained in:
Chris Lattner 2006-12-01 19:50:54 +00:00
parent 63edf03fe5
commit 9dec3a2c0c

View File

@ -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