[PATCH] D143766: [InstCombine][WIP] Fix InstCombinerImpl::foldICmpMulConstant for nsw and nuw mul with unsigned compare.

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 12:20:16 PST 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:2082
           MulTy, APIntOps::RoundingSDiv(C, *MulC, APInt::Rounding::DOWN));
-  } else {
-    assert(Mul->hasNoUnsignedWrap() && "Expected mul nuw");
+  } else if (Mul->hasNoUnsignedWrap()) {
     if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)
----------------
craig.topper wrote:
> goldstein.w.n wrote:
> > Does this need an `ICmpInst::isUnsigned(Pred)` check aswell?
> I didn't add `isUnsigned` because the body of else only checks unsigned predicates and leaves NewC null if it doesn't find an unsigned predicate. NewC being null is sufficient to make the function return null.
Isn't that also true for the signed case? If so maybe drop that check aswell.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143766/new/

https://reviews.llvm.org/D143766



More information about the llvm-commits mailing list