mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-06 04:31:08 +00:00
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
This commit is contained in:
parent
50b5c2ebd9
commit
c15637bafc
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user