[PATCH] D47428: [InstCombine] PR37603: low bit mask canonicalization
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 4 06:49:52 PDT 2018
lebedev.ri added a comment.
In https://reviews.llvm.org/D47428#1120820, @spatel wrote:
> We didn't resolve the 'nuw' question - am I not seeing the scenario that you asked about?
================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:1112
+ Constant *MinusOne = Constant::getAllOnesValue(NBits->getType());
+ auto *Shl = cast<BinaryOperator>(Builder.CreateShl(MinusOne, NBits));
+ // Always NSW. But NUW propagates from `add`.
----------------
spatel wrote:
> Is this always safe to cast rather than dyn_cast? What happens if NBits is a constant expression?
New test with constant seems to work.
So in this case, the constant folding seems to already happen,
but i agree i guess it is better to be proactively safer here.
Repository:
rL LLVM
https://reviews.llvm.org/D47428
More information about the llvm-commits
mailing list