Unit test for SCEV fix r182989, PR16130.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183017 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick 2013-05-31 16:42:41 +00:00
parent 52aaf6a4a9
commit 9c8e1f93b4

View File

@ -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
@ -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:
@ -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
}