[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
Sun Nov 19 08:06:46 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()))) &&
----------------
dtcxzyw wrote:
We can simplify `icmp sle/sgt (srem X, Y), (Y + 1)` into `icmp eq/ne (srem X, Y), (Y + 1)` if we know `Y` is negative.
https://github.com/llvm/llvm-project/pull/72504
More information about the llvm-commits
mailing list