summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-03-08 05:42:00 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-03-08 05:42:00 +0000
commit387d7b1a350cecb09d25bbe0cf62326fdc107ef7 (patch)
tree1a8d606f89d9f0b976a17ca1d9a479fd86fc61ed /llvm/lib
parente94a2f8026848847b60ea008b575123908f4bd52 (diff)
downloadbcm5719-llvm-387d7b1a350cecb09d25bbe0cf62326fdc107ef7.tar.gz
bcm5719-llvm-387d7b1a350cecb09d25bbe0cf62326fdc107ef7.zip
Fix a bug in APIntified ComputeMaskedBits().
llvm-svn: 35022
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 9d327c7883d..02336e59c4c 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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<IntegerType>(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<IntegerType>(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?");
OpenPOWER on IntegriCloud