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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 12:06:45 PST 2023


craig.topper added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:2079
           MulTy, APIntOps::RoundingSDiv(C, *MulC, APInt::Rounding::UP));
     if (Pred == ICmpInst::ICMP_SLE || Pred == ICmpInst::ICMP_SGT)
       NewC = ConstantInt::get(
----------------
goldstein.w.n wrote:
> I'm not sure this is correct w.o `nuw`:
> `nsw` only: https://alive2.llvm.org/ce/z/xrrGmG
> `nsw nuw`: https://alive2.llvm.org/ce/z/CCHqJ8
I think you need to correct the result of the sdiv to round down to match the RoundingSDiv call. sdiv rounds towards 0.

https://alive2.llvm.org/ce/z/c2BQVk




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