[PATCH] D143883: [InstCombine] canonicalize urem as cmp+select
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 17:18:06 PST 2023
Allen marked an inline comment as done.
Allen 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);
----------------
RKSimon wrote:
> 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()) {
> }
> }
> ```
Apply your review, thanks for your detailed example.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143883/new/
https://reviews.llvm.org/D143883
More information about the llvm-commits
mailing list