diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-02-23 23:22:58 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-02-23 23:22:58 +0000 |
| commit | 18c243b933740506b3262e56ef6f9a3a6e4afc08 (patch) | |
| tree | c7bf17f52b360208c3f47dda7953cc30201128e0 /llvm/test/Transforms | |
| parent | c9cf0151cf73ed44dd3af74568a9c01d0bded8b9 (diff) | |
| download | bcm5719-llvm-18c243b933740506b3262e56ef6f9a3a6e4afc08.tar.gz bcm5719-llvm-18c243b933740506b3262e56ef6f9a3a6e4afc08.zip | |
Bugfix: SCEVExpander incorrectly marks increment operations as no-wrap
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.
NOTE: this change was landed with an incorrect commit message in
rL230275 and was reverted for that reason in rL230279. This commit
message is the correct one.
Differential Revision: http://reviews.llvm.org/D7778
llvm-svn: 230280
Diffstat (limited to 'llvm/test/Transforms')
4 files changed, 5 insertions, 5 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/overflowcheck.ll b/llvm/test/Transforms/IndVarSimplify/overflowcheck.ll index 2603f363ab6..3864c6c0cfb 100644 --- a/llvm/test/Transforms/IndVarSimplify/overflowcheck.ll +++ b/llvm/test/Transforms/IndVarSimplify/overflowcheck.ll @@ -9,7 +9,7 @@ target triple = "x86_64-apple-macosx" ; CHECK: @llvm.sadd.with.overflow ; CHECK-LABEL: loop2: ; CHECK-NOT: extractvalue -; CHECK: add nuw nsw +; CHECK: add nuw ; CHECK: @llvm.sadd.with.overflow ; CHECK-LABEL: loop3: ; CHECK-NOT: extractvalue diff --git a/llvm/test/Transforms/IndVarSimplify/pr20680.ll b/llvm/test/Transforms/IndVarSimplify/pr20680.ll index 88a7fd765d0..716e013603a 100644 --- a/llvm/test/Transforms/IndVarSimplify/pr20680.ll +++ b/llvm/test/Transforms/IndVarSimplify/pr20680.ll @@ -204,8 +204,8 @@ for.cond2.for.inc13_crit_edge: ; preds = %for.cond2.for.inc13 br label %for.inc13 ; CHECK: [[for_inc13]]: -; CHECK-NEXT: %[[indvars_iv_next]] = add nuw nsw i32 %[[indvars_iv]], 1 -; CHECK-NEXT: %[[exitcond4:.*]] = icmp ne i32 %[[indvars_iv]], -1 +; CHECK-NEXT: %[[indvars_iv_next]] = add nsw i32 %[[indvars_iv]], 1 +; CHECK-NEXT: %[[exitcond4:.*]] = icmp ne i32 %[[indvars_iv_next]], 0 ; CHECK-NEXT: br i1 %[[exitcond4]], label %[[for_cond2_preheader]], label %[[for_end15:.*]] for.inc13: ; preds = %for.cond2.for.inc13_crit_edge, %for.cond2.preheader %inc14 = add i8 %storemerge15, 1 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] |

