1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-01 16:33:37 +01:00
llvm-mirror/test/Analysis/ScalarEvolution/trip-count10.ll
Dan Gohman cec5b682b6 Fix ScalarEvolution's "exhaustive" trip count evaluation code to avoid
assuming that loops are in canonical form, as ScalarEvolution doesn't
depend on LoopSimplify itself. Also, with indirectbr not all loops can
be simplified. This fixes PR7416.

llvm-svn: 106389
2010-06-19 14:17:24 +00:00

108 lines
2.7 KiB
LLVM

; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
; Trip counts with trivial exit conditions.
; CHECK: Determining loop execution counts for: @a
; CHECK: Loop %loop: Unpredictable backedge-taken count.
; CHECK: Loop %loop: Unpredictable max backedge-taken count.
; CHECK: Determining loop execution counts for: @b
; CHECK: Loop %loop: backedge-taken count is false
; CHECK: Loop %loop: max backedge-taken count is false
; CHECK: Determining loop execution counts for: @c
; CHECK: Loop %loop: backedge-taken count is false
; 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.
define void @a(i64 %n) nounwind {
entry:
%t0 = icmp sgt i64 %n, 0
br i1 %t0, label %loop, label %return
loop:
%i = phi i64 [ %i.next, %loop ], [ 0, %entry ]
%i.next = add nsw i64 %i, 1
%exitcond = icmp eq i64 %i.next, %n
br i1 false, label %return, label %loop
return:
ret void
}
define void @b(i64 %n) nounwind {
entry:
%t0 = icmp sgt i64 %n, 0
br i1 %t0, label %loop, label %return
loop:
%i = phi i64 [ %i.next, %loop ], [ 0, %entry ]
%i.next = add nsw i64 %i, 1
%exitcond = icmp eq i64 %i.next, %n
br i1 true, label %return, label %loop
return:
ret void
}
define void @c(i64 %n) nounwind {
entry:
%t0 = icmp sgt i64 %n, 0
br i1 %t0, label %loop, label %return
loop:
%i = phi i64 [ %i.next, %loop ], [ 0, %entry ]
%i.next = add nsw i64 %i, 1
%exitcond = icmp eq i64 %i.next, %n
br i1 false, label %loop, label %return
return:
ret void
}
define void @d(i64 %n) nounwind {
entry:
%t0 = icmp sgt i64 %n, 0
br i1 %t0, label %loop, label %return
loop:
%i = phi i64 [ %i.next, %loop ], [ 0, %entry ]
%i.next = add nsw i64 %i, 1
%exitcond = icmp eq i64 %i.next, %n
br i1 true, label %loop, label %return
return:
ret void
}
; Trip counts for non-polynomial iterations. It's theoretically possible
; to compute a maximum count for these, but short of that, ScalarEvolution
; should return unknown.
; PR7416
; CHECK: Determining loop execution counts for: @nonpolynomial
; CHECK-NEXT: Loop %loophead: Unpredictable backedge-taken count
; CHECK-NEXT: Loop %loophead: Unpredictable max backedge-taken count
declare i1 @g() nounwind
define void @nonpolynomial() {
entry:
br label %loophead
loophead:
%x = phi i32 [0, %entry], [%x.1, %bb1], [%x.2, %bb2]
%y = icmp slt i32 %x, 100
br i1 %y, label %loopbody, label %retbb
loopbody:
%z = call i1 @g()
br i1 %z, label %bb1, label %bb2
bb1:
%x.1 = add i32 %x, 2
br label %loophead
bb2:
%x.2 = add i32 %x, 3
br label %loophead
retbb:
ret void
}