Skip to content

Commit 46828d2

Browse files
committed
Revert "[InstCombine] Combine and->cmp->sel->or-disjoint into and->mul (#135274)"
This reverts commit c49c7dd.
1 parent 2c9a727 commit 46828d2

File tree

2 files changed

+0
-371
lines changed

2 files changed

+0
-371
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,49 +3674,6 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
36743674
foldAddLikeCommutative(I.getOperand(1), I.getOperand(0),
36753675
/*NSW=*/true, /*NUW=*/true))
36763676
return R;
3677-
3678-
Value *Cond0 = nullptr, *Cond1 = nullptr;
3679-
const APInt *Op0Eq = nullptr, *Op0Ne = nullptr;
3680-
const APInt *Op1Eq = nullptr, *Op1Ne = nullptr;
3681-
3682-
// (!(A & N) ? 0 : N * C) + (!(A & M) ? 0 : M * C) -> A & (N + M) * C
3683-
if (match(I.getOperand(0),
3684-
m_Select(m_Value(Cond0), m_APInt(Op0Eq), m_APInt(Op0Ne))) &&
3685-
match(I.getOperand(1),
3686-
m_Select(m_Value(Cond1), m_APInt(Op1Eq), m_APInt(Op1Ne)))) {
3687-
3688-
auto LHSDecompose =
3689-
decomposeBitTest(Cond0, /*LookThruTrunc=*/true,
3690-
/*AllowNonZeroC=*/false, /*DecomposeAnd=*/true);
3691-
auto RHSDecompose =
3692-
decomposeBitTest(Cond1, /*LookThruTrunc=*/true,
3693-
/*AllowNonZeroC=*/false, /*DecomposeAnd=*/true);
3694-
3695-
if (LHSDecompose && RHSDecompose && LHSDecompose->X == RHSDecompose->X &&
3696-
RHSDecompose->Mask.isPowerOf2() && LHSDecompose->Mask.isPowerOf2() &&
3697-
LHSDecompose->Mask != RHSDecompose->Mask) {
3698-
assert(ICmpInst::isEquality(LHSDecompose->Pred));
3699-
if (LHSDecompose->Pred == ICmpInst::ICMP_NE)
3700-
std::swap(Op0Eq, Op0Ne);
3701-
if (RHSDecompose->Pred == ICmpInst::ICMP_NE)
3702-
std::swap(Op1Eq, Op1Ne);
3703-
3704-
if (!Op0Ne->isZero() && !Op1Ne->isZero() && Op0Eq->isZero() &&
3705-
Op1Eq->isZero() && Op0Ne->urem(LHSDecompose->Mask).isZero() &&
3706-
Op1Ne->urem(RHSDecompose->Mask).isZero() &&
3707-
Op0Ne->udiv(LHSDecompose->Mask) ==
3708-
Op1Ne->udiv(RHSDecompose->Mask)) {
3709-
auto NewAnd = Builder.CreateAnd(
3710-
LHSDecompose->X,
3711-
ConstantInt::get(LHSDecompose->X->getType(),
3712-
(LHSDecompose->Mask + RHSDecompose->Mask)));
3713-
3714-
return BinaryOperator::CreateMul(
3715-
NewAnd, ConstantInt::get(NewAnd->getType(),
3716-
Op0Ne->udiv(LHSDecompose->Mask)));
3717-
}
3718-
}
3719-
}
37203677
}
37213678

37223679
Value *X, *Y;

llvm/test/Transforms/InstCombine/or-bitmask.ll

Lines changed: 0 additions & 328 deletions
This file was deleted.

0 commit comments

Comments
 (0)