Skip to content

Commit

Permalink
Unit test for SCEV fix r182989, PR16130.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183017 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
atrick committed May 31, 2013
1 parent 52aaf6a commit 9c8e1f9
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions test/Analysis/ScalarEvolution/trip-count10.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
; Trip counts with trivial exit conditions.

; CHECK: Determining loop execution counts for: @a
; CHECK: Loop %loop: Unpredictable backedge-taken count.
; CHECK: Loop %loop: Unpredictable backedge-taken count.
; CHECK: Loop %loop: Unpredictable max backedge-taken count.

; CHECK: Determining loop execution counts for: @b
Expand All @@ -15,8 +15,8 @@
; CHECK: Loop %loop: max backedge-taken count is false

; CHECK: Determining loop execution counts for: @d
; CHECK: Loop %loop: Unpredictable backedge-taken count.
; CHECK: Loop %loop: Unpredictable max backedge-taken count.
; CHECK: Loop %loop: Unpredictable backedge-taken count.
; CHECK: Loop %loop: Unpredictable max backedge-taken count.

define void @a(i64 %n) nounwind {
entry:
Expand Down Expand Up @@ -124,3 +124,28 @@ loop:
return:
ret void
}

; PR16130: Loop exit depends on an 'or' expression.
; One side of the expression test against a value that will be skipped.
; We can't assume undefined behavior just because we have an NSW flag.
;
; CHECK: Determining loop execution counts for: @exit_orcond_nsw
; CHECK: Loop %for.body.i: Unpredictable backedge-taken count.
; CHECK: Loop %for.body.i: max backedge-taken count is 1
define void @exit_orcond_nsw(i32 *%a) nounwind {
entry:
br label %for.body.i

for.body.i: ; preds = %for.body.i, %entry
%b.01.i = phi i32 [ 0, %entry ], [ %add.i, %for.body.i ]
%tobool.i = icmp ne i32 %b.01.i, 0
%add.i = add nsw i32 %b.01.i, 8
%cmp.i = icmp eq i32 %add.i, 13
%or.cond = or i1 %tobool.i, %cmp.i
br i1 %or.cond, label %exit, label %for.body.i

exit: ; preds = %for.body.i
%b.01.i.lcssa = phi i32 [ %b.01.i, %for.body.i ]
store i32 %b.01.i.lcssa, i32* %a, align 4
ret void
}

0 comments on commit 9c8e1f9

Please sign in to comment.