diff options
author | Chris Lattner <sabre@nondot.org> | 2006-02-13 06:09:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-02-13 06:09:08 +0000 |
commit | c15637bafc57de7d1775082910bff4cc59c4f0db (patch) | |
tree | ccdc1bf3659af1ebdc5c456f9de5e89c129824fb | |
parent | 50b5c2ebd91c3fec75750b53880ff04048a043d4 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26138 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 9b75ee13cb..4247d8a6e2 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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(); |