[llvm] Simplify `(a % b) lt/ge (b-1)` into `(a % b) eq/ne (b-1)` (PR #72504)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 27 11:26:38 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()))) &&
+ isKnownNonNegative(Y, DL, 0, Q.AC, Q.CxtI, Q.DT)) ||
----------------
dtcxzyw wrote:
Please rebase on https://github.com/llvm/llvm-project/commit/4b3ea337ad188d5c3ff05bf64cc61c3355e66376.
https://github.com/llvm/llvm-project/pull/72504
More information about the llvm-commits
mailing list