From 9a28daa86444bd5e68ca58d6ceebce961b03cb86 Mon Sep 17 00:00:00 2001 From: Zhou Sheng Date: Thu, 8 Mar 2007 05:42:00 +0000 Subject: [PATCH] Fix a bug in APIntified ComputeMaskedBits(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35022 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 9d327c7883d..02336e59c4c 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -675,11 +675,9 @@ static void ComputeMaskedBits(Value *V, APInt Mask, APInt& KnownZero, case Instruction::ZExt: { // Compute the bits in the result that are not present in the input. const IntegerType *SrcTy = cast(I->getOperand(0)->getType()); - APInt NotIn(~SrcTy->getMask()); - APInt NewBits = APInt::getAllOnesValue(BitWidth) & - NotIn.zext(BitWidth); + APInt NewBits(APInt::getAllOnesValue(BitWidth).shl(SrcTy->getBitWidth())); - Mask &= ~NotIn; + Mask &= SrcTy->getMask().zext(BitWidth); ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1); assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); // The top bits are known to be zero. @@ -689,11 +687,9 @@ static void ComputeMaskedBits(Value *V, APInt Mask, APInt& KnownZero, case Instruction::SExt: { // Compute the bits in the result that are not present in the input. const IntegerType *SrcTy = cast(I->getOperand(0)->getType()); - APInt NotIn(~SrcTy->getMask()); - APInt NewBits = APInt::getAllOnesValue(BitWidth) & - NotIn.zext(BitWidth); + APInt NewBits(APInt::getAllOnesValue(BitWidth).shl(SrcTy->getBitWidth())); - Mask &= ~NotIn; + Mask &= SrcTy->getMask().zext(BitWidth); ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1); assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); -- 2.34.1