[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
Thu Dec 19 04:21:41 PST 2019


shchenz marked an inline comment as done.
shchenz added inline comments.


================
Comment at: llvm/test/Transforms/IndVarSimplify/lftr-pr31181.ll:332
 ; CHECK:       always_taken:
-; CHECK-NEXT:    [[IV2_INC]] = add nsw i32 [[IV2]], 1
+; CHECK-NEXT:    [[IV2_INC]] = add i32 [[IV2]], 1
 ; CHECK-NEXT:    [[IV_INC]] = add nsw i32 [[IV]], 1
----------------
nikic wrote:
> Aren't these two test changes regressions?
Hi @nikic , thanks for your quick comment. For my understanding, seems the changes are improvement instead of regression. 
Before LFTR, we use `%iv` as loop iteration variable, the loop count `loop_count` is  `abs(-2147483648) + 20` (`-2147483648` is `SINT32_MIN`). For the increase expression `%iv.inc = add nsw i32 %iv, 1`, it will not generate poison value(no overflow happens for the loop before transformation). 
After LFTR, we use `%iv2` as loop iteration variable, `%iv2` start-value is -2, so to iterates times `loop_count` (21 bigger than SINT32_MAX), expression `[[IV2_INC]] = add nsw i32 [[IV2]], 1` will surely overflow, thus we will get poison value. 
But after the change, no `nsw` anymore, so no poison value, we will do wrap to reach  `loop_count` times iterations. 
Could you please help to point out where am I wrong? 


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

https://reviews.llvm.org/D71690





More information about the llvm-commits mailing list