[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
Fri Jan 12 02:12:12 PST 2024


================
@@ -6855,6 +6855,50 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
   if (Value *V = simplifyICmpInst(I.getPredicate(), Op0, Op1, Q))
     return replaceInstUsesWith(I, V);
 
+  {
+    Value *X;
+    const APInt *C1, *C2;
+    ICmpInst::Predicate Pred;
+    if ((match(&I, m_ICmp(Pred, m_SRem(m_Value(X), m_NonNegative(C1)),
----------------
dtcxzyw wrote:

This part looks good to me.


https://github.com/llvm/llvm-project/pull/72504


More information about the llvm-commits mailing list