[llvm] [InstCombine] Implemented missed optimization in muldivrem (PR #140916)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 2 01:24:48 PDT 2025
================
@@ -1316,6 +1316,15 @@ Instruction *InstCombinerImpl::commonIDivTransforms(BinaryOperator &I) {
Value *X;
const APInt *C1;
+ // (X mod(C1 *C2)/C2) -> (X/C2) mod(C1)
+ if ((IsSigned && match(Op0, m_SRem(m_Value(X), m_NSWMul(m_APInt(C1), m_APInt(C2))))) ||
----------------
nikic wrote:
This is never going to match anything: The multiply of C1*C2 will fold to a constant. You need to match a constant and then separately check whether that constant is a multiple of the other constant.
https://github.com/llvm/llvm-project/pull/140916
More information about the llvm-commits
mailing list