summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-02-13 06:09:08 +0000
committerChris Lattner <sabre@nondot.org>2006-02-13 06:09:08 +0000
commit68e74757776274ea9e298752686a10e6fddfe538 (patch)
treece8a90b1b56e9b28898923b519330e647670ccf9 /llvm/lib/Transforms
parent0684e9ae6d97cf2a0e6b2d45a190b9f962e8e352 (diff)
downloadbcm5719-llvm-68e74757776274ea9e298752686a10e6fddfe538.tar.gz
bcm5719-llvm-68e74757776274ea9e298752686a10e6fddfe538.zip
Be careful not to request or look at bits shifted in from outside the size
of the input. This fixes the mediabench/gsm/toast failure last night. llvm-svn: 26138
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 9b75ee13cb6..4247d8a6e29 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -939,20 +939,26 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t DemandedMask,
// Compute the new bits that are at the top now.
uint64_t HighBits = (1ULL << ShAmt)-1;
HighBits <<= I->getType()->getPrimitiveSizeInBits() - ShAmt;
-
+ uint64_t TypeMask = I->getType()->getIntegralTypeMask();
if (I->getType()->isUnsigned()) { // Unsigned shift right.
- if (SimplifyDemandedBits(I->getOperand(0), DemandedMask << ShAmt,
+ if (SimplifyDemandedBits(I->getOperand(0),
+ (DemandedMask << ShAmt) & TypeMask,
KnownZero, KnownOne, Depth+1))
return true;
assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
+ KnownZero &= TypeMask;
+ KnownOne &= TypeMask;
KnownZero >>= ShAmt;
KnownOne >>= ShAmt;
KnownZero |= HighBits; // high bits known zero.
} else { // Signed shift right.
- if (SimplifyDemandedBits(I->getOperand(0), DemandedMask << ShAmt,
+ if (SimplifyDemandedBits(I->getOperand(0),
+ (DemandedMask << ShAmt) & TypeMask,
KnownZero, KnownOne, Depth+1))
return true;
assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
+ KnownZero &= TypeMask;
+ KnownOne &= TypeMask;
KnownZero >>= SA->getValue();
KnownOne >>= SA->getValue();
OpenPOWER on IntegriCloud