[llvm] Fold (a % b) lt/ge (b-1) where b is a power of 2 (PR #72504)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 19 01:46:53 PST 2023
================
@@ -6837,6 +6837,25 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
Changed = true;
}
+ {
+ Value *X, *Y;
+ const APInt *C;
+ ICmpInst::Predicate Pred = I.getPredicate();
+ if ((Pred == ICmpInst::ICMP_SGE || Pred == ICmpInst::ICMP_SLT) &&
+ match(Op0, m_OneUse(m_SRem(m_Value(X), m_Value(Y)))) &&
+ ((match(Op1, m_OneUse(m_c_Add(m_Deferred(Y), m_AllOnes()))) &&
----------------
elhewaty wrote:
how can we apply this optimization with negative divisors?
https://github.com/llvm/llvm-project/pull/72504
More information about the llvm-commits
mailing list