[PATCH] D64869: [SCEV] get more accurate range for AddExpr with NW flag

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 00:23:52 PDT 2019


shchenz marked 2 inline comments as done.
shchenz added inline comments.


================
Comment at: llvm/lib/IR/ConstantRange.cpp:829
+  assert(
+      (NoWrapKind == OBO::NoSignedWrap || NoWrapKind == OBO::NoUnsignedWrap) &&
+      "NoWrapKind invalid!");
----------------
reames wrote:
> Why not allow both?
I think we can not support both wrap type in one range type(unsigned/signed range). We have signed and unsigned range for one SCEV and we set `nsw` only based on signed range and `nuw` only based on unsigned range. For example, if one ADD SCEV's signed range is [-10, 20), and its unsigned range is [10, 20), in `StrengthenNoWrapFlags`, we will set this SCEV with `nsw` and `nuw`. But when we wants to get its range after nsw and nuw are set, `MGNR` unsigned wrap for [-10, 20)  is [0, 1), after intersect with [10, 20), we get empty set for this SCEV for both signed range and unsigned range. This is not right. we should handle `nsw` for signed range and `nuw` for unsigned range.


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

https://reviews.llvm.org/D64869





More information about the llvm-commits mailing list