[PATCH] D69960: [ConstantRange] Add `ushl_sat()`/`sshl_sat()` methods.
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 13:18:39 PST 2019
lebedev.ri added a comment.
lebedev.ri added inline comments.
================
Comment at: llvm/lib/IR/ConstantRange.cpp:1359
+ NewU = getSignedMax().sshl_sat(Other.getUnsignedMax()) + 1;
+ }
+ return getNonEmpty(std::move(NewL), std::move(NewU));
----------------
nikic wrote:
> Wondering if a formulation along the lines of
>
> ```
> APInt Min = getSignedMin(), Max = getSignedMax();
> APInt ShiftMin = getUnsignedMin(), ShiftMax = getUnsignedMax();
> APInt NewL = Min.sshl_sat(Min.isNonNegative() ? ShiftMin : ShiftMax);
> APInt NewU = Max.sshl_sat(Max.isNonNegative() ? ShiftMax : ShiftMin) + 1;
> ```
>
> might be cleaner?
A bit, yes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69960/new/
https://reviews.llvm.org/D69960
More information about the llvm-commits
mailing list