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

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 9 08:21:22 PDT 2025


================
@@ -2473,6 +2473,16 @@ Instruction *InstCombinerImpl::visitURem(BinaryOperator &I) {
     }
   }
 
+  Value *A;
+  const APInt *Op1Cst, *BCst;
+  // urem(urem(A, BCst), Op1Cst) -> urem(A, Op1Cst)
+  // iff urem(BCst, Op1Cst) == 0
+  if (match(Op0, m_URem(m_Value(A), m_APInt(BCst))) &&
----------------
kper wrote:

ok, can you rerun the benchmark? (I am not sure whether I need rights for that)

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


More information about the llvm-commits mailing list