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

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 10 23:03:49 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:

I am not sure what's here left for me to do
Should I close this PR because it seems to be unprofitable to do the optimisation?

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


More information about the llvm-commits mailing list