[PATCH] D156845: [ConstantRange] Calculate precise range for shl by -1
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 18:11:12 PDT 2023
Allen added inline comments.
================
Comment at: llvm/lib/IR/ConstantRange.cpp:1485
// There's overflow!
- if (OtherMax.ugt(Max.countl_zero()))
+ if (OtherMax.ugt(Max.countl_zero()) && !Neg)
return getFull();
----------------
goldstein.w.n wrote:
> You can either drop the `!Neg` here (my opinion) or drop the `OtherMax.ule(Max...)` in `Neg` definition.
>
> If `OtherMax.ugt(...)` is true, `Neg` will always be false.
> If `OtherMax.ule(...)` is false, then this if statement here will ensure `Neg` is valid after.
thanks for your comment.
the **OtherMax.ule(Max.abs()...)** in Neg definition has extra **abs()**, so this is different from the origin **OtherMax.ugt(...)** ?
For example, if the Max type is i8, then -1 is 255, so **Max.countl_zero()** is 0, so the **negative value Max** will return getFull(), and the **Neg** condition is used to skip this blockage.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156845/new/
https://reviews.llvm.org/D156845
More information about the llvm-commits
mailing list