[PATCH] D156845: [ConstantRange] Calculate precise range for shl by -1
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 25 00:00:28 PDT 2023
Allen marked an inline comment as done.
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:
> Allen wrote:
> > 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.
> I missed that but you still changed the codes. Was it not an issue afterall?
Yes, it is an issue, and the case **Clang :: CodeGenOpenCL/shifts.c** will failure.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156845/new/
https://reviews.llvm.org/D156845
More information about the llvm-commits
mailing list