[llvm] [InstCombine]: Eliminate redundant modulus for urem (PR #157644)

Hongyu Chen via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 9 04:06:05 PDT 2025


================
@@ -2473,6 +2473,14 @@ Instruction *InstCombinerImpl::visitURem(BinaryOperator &I) {
     }
   }
 
+  Value *A;
+  Value *B;
+  // urem(urem(A, B), Op1) -> urem(A, Op1)
+  if (match(Op0, m_URem(m_Value(A), m_Value(B)))) {
----------------
XChy wrote:

Lack the check in the general proof.
```llvm 
 %m = urem i4 %mod0, %mod1
 %mz = icmp eq i4 %m, 0
 call void @llvm.assume(i1 %mz)
```

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


More information about the llvm-commits mailing list