[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:27:35 PST 2023
craig.topper 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)
----------------
goldstein.w.n wrote:
> 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.
It is true, but I need it to still go to the else if the condition isn't signed.
Alternatively, I could remove the else and write.
```
if (NSW) {
....
}
if (!NewC && NUW) {
}
```
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