[llvm] [InstCombine] Extend `foldICmpAddConstant` to disjoint `or`. (PR #75899)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 20 14:08:25 PST 2024
================
@@ -2953,23 +2955,24 @@ Instruction *InstCombinerImpl::foldICmpAddConstant(ICmpInst &Cmp,
Table[1] = ComputeTable(false, true);
Table[2] = ComputeTable(true, false);
Table[3] = ComputeTable(true, true);
- if (auto *Cond =
- createLogicFromTable(Table, Op0, Op1, Builder, Add->hasOneUse()))
+ if (auto *Cond = createLogicFromTable(Table, Op0, Op1, Builder,
+ AddLike->hasOneUse()))
return replaceInstUsesWith(Cmp, Cond);
}
const APInt *C2;
if (Cmp.isEquality() || !match(Y, m_APInt(C2)))
return nullptr;
// Fold icmp pred (add X, C2), C.
- Type *Ty = Add->getType();
+ Type *Ty = AddLike->getType();
// If the add does not wrap, we can always adjust the compare by subtracting
// the constants. Equality comparisons are handled elsewhere. SGE/SLE/UGE/ULE
// are canonicalized to SGT/SLT/UGT/ULT.
- if ((Add->hasNoSignedWrap() &&
+ if (AddLike->getOpcode() == Instruction::Or ||
----------------
goldsteinn wrote:
Does the `or` case need a check that `pred` is not true when equals?
https://github.com/llvm/llvm-project/pull/75899
More information about the llvm-commits
mailing list