[PATCH] D71690: [SCEV] get a more accurate range for AddRecExpr with nuw flag

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 23 02:20:01 PST 2019


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:5661
+        MinValue = getUnsignedRangeMin(AddRec->getStart());
+      else {
+        ConstantRange StartRange =
----------------
shchenz wrote:
> sanjoy.google wrote:
> > Can you comment on why you need the else block?
> If we use `getUnsignedRangeMin(AddRec->getStart())` as minimum value for SignedRange of the start of AddRec, we may get wrong result. For example, assuming we get range `[137, 227)` as result of `getUnsignedRangeMin(AddRec->getStart());` for type `i8`,  if we want to return it as SignedRange, it will be `[-119, -29)`, this is invalid range for AddRec with `nuw` even for SignedRange?
Why is `[-119, -29)` an invalid range?


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

https://reviews.llvm.org/D71690





More information about the llvm-commits mailing list