mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-16 00:33:10 +00:00
If any of the sign extended bits are demanded, the input sign bit is demanded
for a sign extension. This fixes InstCombine/2006-02-13-DemandedMiscompile.ll and Ptrdist/bc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26152 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3fcb664dbc
commit
f345fe4d9a
@ -889,15 +889,21 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t DemandedMask,
|
|||||||
KnownZero |= NewBits;
|
KnownZero |= NewBits;
|
||||||
} else {
|
} else {
|
||||||
// Sign extension.
|
// Sign extension.
|
||||||
if (SimplifyDemandedBits(I->getOperand(0),
|
uint64_t InSignBit = 1ULL << (SrcTy->getPrimitiveSizeInBits()-1);
|
||||||
DemandedMask & SrcTy->getIntegralTypeMask(),
|
int64_t InputDemandedBits = DemandedMask & SrcTy->getIntegralTypeMask();
|
||||||
|
|
||||||
|
// If any of the sign extended bits are demanded, we know that the sign
|
||||||
|
// bit is demanded.
|
||||||
|
if (NewBits & DemandedMask)
|
||||||
|
InputDemandedBits |= InSignBit;
|
||||||
|
|
||||||
|
if (SimplifyDemandedBits(I->getOperand(0), InputDemandedBits,
|
||||||
KnownZero, KnownOne, Depth+1))
|
KnownZero, KnownOne, Depth+1))
|
||||||
return true;
|
return true;
|
||||||
assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
|
assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
|
||||||
|
|
||||||
// If the sign bit of the input is known set or clear, then we know the
|
// If the sign bit of the input is known set or clear, then we know the
|
||||||
// top bits of the result.
|
// top bits of the result.
|
||||||
uint64_t InSignBit = 1ULL << (SrcTy->getPrimitiveSizeInBits()-1);
|
|
||||||
|
|
||||||
// If the input sign bit is known zero, or if the NewBits are not demanded
|
// If the input sign bit is known zero, or if the NewBits are not demanded
|
||||||
// convert this into a zero extension.
|
// convert this into a zero extension.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user