mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 03:24:09 +00:00
[InstCombine] Use a more targeted fix instead of r235544
Only clear out the NSW/NUW flags if we are optimizing 'add'/'sub' while taking advantage that the sign bit is not set. We do this optimization to further shrink the mask but shrinking the mask isn't NSW/NUW preserving in this case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235558 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -88,13 +88,6 @@ bool InstCombiner::SimplifyDemandedBits(Use &U, APInt DemandedMask,
|
||||
KnownOne, Depth, UserI);
|
||||
if (!NewVal) return false;
|
||||
U = NewVal;
|
||||
|
||||
// Shrinking a constant might cause a nsw/nuw violation to occur in
|
||||
// instructions which are themselves demanded.
|
||||
if (auto *UserOBO = dyn_cast<OverflowingBinaryOperator>(UserI)) {
|
||||
cast<BinaryOperator>(UserOBO)->setHasNoSignedWrap(false);
|
||||
cast<BinaryOperator>(UserOBO)->setHasNoUnsignedWrap(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -607,8 +600,11 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
if (SimplifyDemandedBits(I->getOperandUse(0), DemandedFromOps,
|
||||
LHSKnownZero, LHSKnownOne, Depth + 1) ||
|
||||
SimplifyDemandedBits(I->getOperandUse(1), DemandedFromOps,
|
||||
LHSKnownZero, LHSKnownOne, Depth + 1))
|
||||
LHSKnownZero, LHSKnownOne, Depth + 1)) {
|
||||
cast<BinaryOperator>(I)->setHasNoSignedWrap(false);
|
||||
cast<BinaryOperator>(I)->setHasNoUnsignedWrap(false);
|
||||
return I;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -624,8 +620,11 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
if (SimplifyDemandedBits(I->getOperandUse(0), DemandedFromOps,
|
||||
LHSKnownZero, LHSKnownOne, Depth + 1) ||
|
||||
SimplifyDemandedBits(I->getOperandUse(1), DemandedFromOps,
|
||||
LHSKnownZero, LHSKnownOne, Depth + 1))
|
||||
LHSKnownZero, LHSKnownOne, Depth + 1)) {
|
||||
cast<BinaryOperator>(I)->setHasNoSignedWrap(false);
|
||||
cast<BinaryOperator>(I)->setHasNoUnsignedWrap(false);
|
||||
return I;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise just hand the sub off to computeKnownBits to fill in
|
||||
|
Reference in New Issue
Block a user