mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Always compute all the bits in ComputeMaskedBits.
This allows us to keep passing reduced masks to SimplifyDemandedBits, but know about all the bits if SimplifyDemandedBits fails. This allows instcombine to simplify cases like the one in the included testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154011 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -141,10 +141,9 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
// a sub and fuse this add with it.
|
||||
if (LHS->hasOneUse() && (XorRHS->getValue()+1).isPowerOf2()) {
|
||||
IntegerType *IT = cast<IntegerType>(I.getType());
|
||||
APInt Mask = APInt::getAllOnesValue(IT->getBitWidth());
|
||||
APInt LHSKnownOne(IT->getBitWidth(), 0);
|
||||
APInt LHSKnownZero(IT->getBitWidth(), 0);
|
||||
ComputeMaskedBits(XorLHS, Mask, LHSKnownZero, LHSKnownOne);
|
||||
ComputeMaskedBits(XorLHS, LHSKnownZero, LHSKnownOne);
|
||||
if ((XorRHS->getValue() | LHSKnownZero).isAllOnesValue())
|
||||
return BinaryOperator::CreateSub(ConstantExpr::getAdd(XorRHS, CI),
|
||||
XorLHS);
|
||||
@@ -202,14 +201,13 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
|
||||
// A+B --> A|B iff A and B have no bits set in common.
|
||||
if (IntegerType *IT = dyn_cast<IntegerType>(I.getType())) {
|
||||
APInt Mask = APInt::getAllOnesValue(IT->getBitWidth());
|
||||
APInt LHSKnownOne(IT->getBitWidth(), 0);
|
||||
APInt LHSKnownZero(IT->getBitWidth(), 0);
|
||||
ComputeMaskedBits(LHS, Mask, LHSKnownZero, LHSKnownOne);
|
||||
ComputeMaskedBits(LHS, LHSKnownZero, LHSKnownOne);
|
||||
if (LHSKnownZero != 0) {
|
||||
APInt RHSKnownOne(IT->getBitWidth(), 0);
|
||||
APInt RHSKnownZero(IT->getBitWidth(), 0);
|
||||
ComputeMaskedBits(RHS, Mask, RHSKnownZero, RHSKnownOne);
|
||||
ComputeMaskedBits(RHS, RHSKnownZero, RHSKnownOne);
|
||||
|
||||
// No bits in common -> bitwise or.
|
||||
if ((LHSKnownZero|RHSKnownZero).isAllOnesValue())
|
||||
|
Reference in New Issue
Block a user