[llvm] [InstCombine] Guard foldICmpSRemConstant against zero divisors (PR #173702)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 26 23:01:30 PST 2025
================
@@ -2668,17 +2668,17 @@ Instruction *InstCombinerImpl::foldICmpSRemConstant(ICmpInst &Cmp,
const APInt *DivisorC;
if (!match(SRem->getOperand(1), m_APInt(DivisorC)))
return nullptr;
+ if (DivisorC->isZero())
+ return nullptr;
APInt NormalizedC = C;
if (Pred == ICmpInst::ICMP_ULT) {
- assert(!NormalizedC.isZero() &&
- "ult X, 0 should have been simplified already.");
+ if (NormalizedC.isZero())
----------------
dtcxzyw wrote:
You don't need to remove this assertion. It should be guarded by simplifyICmpInst
https://github.com/llvm/llvm-project/pull/173702
More information about the llvm-commits
mailing list