[PATCH] D139598: [InstCombine] Fold (X << Z) / (X * Y) -> (1 << Z) / Y
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 00:25:52 PST 2022
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:1062
+ return BinaryOperator::CreateUDiv(
+ Builder.CreateShl(ConstantInt::get(Ty, 1), Z), Y);
+ }
----------------
Chenbing.Zheng wrote:
> RKSimon wrote:
> > arsenm wrote:
> > > Can you preserve NUW and exact?
> > Move the !IsSigned check outside to avoid the cost of match calls?
> I preserve exact, but it seems that NUW is unnecessary when Op0 of SHL is 1 ?
You're right that we can infer nuw for `1 << x`, but based on your tests it doesn't look like we actually do this...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139598/new/
https://reviews.llvm.org/D139598
More information about the llvm-commits
mailing list