diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-02-25 20:02:59 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-02-25 20:02:59 +0000 |
commit | dcc84db2641eaff6efece8502ccc5f3863ef9356 (patch) | |
tree | d7b3f768f3dc130cc5a3b27c640e23f815c434fb /llvm/test/Transforms/LoopStrengthReduce | |
parent | f42e1eca9fe959059079abf0dda590c23fddfb14 (diff) | |
download | bcm5719-llvm-dcc84db2641eaff6efece8502ccc5f3863ef9356.tar.gz bcm5719-llvm-dcc84db2641eaff6efece8502ccc5f3863ef9356.zip |
Bugfix: SCEVExpander incorrectly marks increment operations as no-wrap
(The change was landed in r230280 and caused the regression PR22674.
This version contains a fix and a test-case for PR22674).
When emitting the increment operation, SCEVExpander marks the
operation as nuw or nsw based on the flags on the preincrement SCEV.
This is incorrect because, for instance, it is possible that {-6,+,1}
is <nuw> while {-6,+,1}+1 = {-5,+,1} is not.
This change teaches SCEV to mark the increment as nuw/nsw only if it
can explicitly prove that the increment operation won't overflow.
Apart from the attached test case, another (more realistic)
manifestation of the bug can be seen in
Transforms/IndVarSimplify/pr20680.ll.
Differential Revision: http://reviews.llvm.org/D7778
llvm-svn: 230533
Diffstat (limited to 'llvm/test/Transforms/LoopStrengthReduce')
-rw-r--r-- | llvm/test/Transforms/LoopStrengthReduce/count-to-zero.ll | 2 | ||||
-rw-r--r-- | llvm/test/Transforms/LoopStrengthReduce/uglygep.ll | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/llvm/test/Transforms/LoopStrengthReduce/count-to-zero.ll b/llvm/test/Transforms/LoopStrengthReduce/count-to-zero.ll index feb79f8a0c7..0e96f02904d 100644 --- a/llvm/test/Transforms/LoopStrengthReduce/count-to-zero.ll +++ b/llvm/test/Transforms/LoopStrengthReduce/count-to-zero.ll @@ -19,7 +19,7 @@ bb3: ; preds = %bb1 %tmp4 = add i32 %c_addr.1, -1 ; <i32> [#uses=1] %c_addr.1.be = select i1 %tmp2, i32 %tmp3, i32 %tmp4 ; <i32> [#uses=1] %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1] -; CHECK: add i32 %lsr.iv, -1 +; CHECK: add nsw i32 %lsr.iv, -1 br label %bb6 bb6: ; preds = %bb3, %entry diff --git a/llvm/test/Transforms/LoopStrengthReduce/uglygep.ll b/llvm/test/Transforms/LoopStrengthReduce/uglygep.ll index 4562d29a0a2..51550873415 100644 --- a/llvm/test/Transforms/LoopStrengthReduce/uglygep.ll +++ b/llvm/test/Transforms/LoopStrengthReduce/uglygep.ll @@ -59,7 +59,7 @@ bb: ; CHECK: loop0: ; Induction variable is initialized to -2. ; CHECK-NEXT: [[PHIIV:%[^ ]+]] = phi i32 [ [[IVNEXT:%[^ ]+]], %loop0 ], [ -2, %bb ] -; CHECK-NEXT: [[IVNEXT]] = add i32 [[PHIIV]], 1 +; CHECK-NEXT: [[IVNEXT]] = add nuw nsw i32 [[PHIIV]], 1 ; CHECK-NEXT: br i1 false, label %loop0, label %bb0 loop0: ; preds = %loop0, %bb %i0 = phi i32 [ %i0.next, %loop0 ], [ 0, %bb ] ; <i32> [#uses=2] |