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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 9 09:10:42 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))) &&
----------------
nikic wrote:

It looks like with this change the fold never triggers anymore...

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


More information about the llvm-commits mailing list