[PATCH] D143883: [InstCombine] canonicalize urem as cmp+select
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 04:49:03 PST 2023
RKSimon added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:1792
+ if (match(Op0, m_NUWAdd(m_Value(X), m_One())) &&
+ simplifyICmpWithDominatingAssume(ICmpInst::ICMP_ULT, X, Op1, SQ, &I)) {
+ Value *Cmp = Builder.CreateICmpEQ(Op0, Op1);
----------------
Allen wrote:
> nikic wrote:
> > Why is this specific to assumes? Can we do a generic simplifyICmp? (If we do so, Op0 needs to be frozen.)
> Apply your comment, thanks
Would this be better? I always hate to see isa<> + cast<> pairs - it feels like we're duplicating work.
```
if (auto *CVal = dyn_cast_or_null<Constant>(Val)) {
if (CVal->isOneValue()) {
}
}
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143883/new/
https://reviews.llvm.org/D143883
More information about the llvm-commits
mailing list