[PATCH] D156845: [ConstantRange] Calculate precise range for shl by -1

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 09:52:07 PDT 2023


goldstein.w.n 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();
----------------
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.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156845/new/

https://reviews.llvm.org/D156845



More information about the llvm-commits mailing list