[PATCH] D71690: [SCEV] get a more accurate range for AddRecExpr with nuw flag
ChenZheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 29 19:50:25 PST 2019
shchenz marked an inline comment as done.
shchenz added inline comments.
================
Comment at: llvm/test/Analysis/ScalarEvolution/range_nw_flag.ll:23
; CHECK-LABEL: @test-addrec-nuw
-; CHECK: --> {(1 + (10 smax %offset))<nuw>,+,1}<nuw><%loop> U: full-set S: full-set
+; CHECK: --> {(1 + (10 smax %offset))<nuw>,+,1}<nuw><%loop> U: [11,0) S: full-set
define void @test-addrec-nuw(float* %input, i32 %offset, i32 %numIterations) {
----------------
For signed range, I think here it should also be [11,0).
but seems, there is a legacy issue for start SCEV signed range: `{(1 + (10 smax %offset))<nuw>,+,1}<nuw><%loop>`.
signed range for `(10 smax %offset)` is `[10, SINT_MIN)`
`(1 + (10 smax %offset))<nuw>` signed range should be `[11, SINT_MIN)`, instead of full-set? @nikic
Even with the change in https://reviews.llvm.org/D64869 which takes `nuw` for add into account, we still get full-set as result.
Flow in `addWithNoWrap`:
normal add result for (1 + [10, SINT_MIN))<nuw> is `[11, SINT_MIN +1)`
uadd_sat result for (1 + [10, SINT_MIN))<nuw> is also `[11, SINT_MIN +1)`, so final result is `[11, SINT_MIN +1)`, currently this range is treated as signed wrap range. (Min value is not SINT_MIN)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71690/new/
https://reviews.llvm.org/D71690
More information about the llvm-commits
mailing list