Changed renaming of local symbols by inserting a dot vefore the numeric suffix.
[oota-llvm.git] / test / Transforms / PlaceSafepoints / finite-loops.ll
1 ; Tests to ensure that we are not placing backedge safepoints in
2 ; loops which are clearly finite.
3 ;; RUN: opt %s -place-safepoints -S | FileCheck %s
4
5
6 ; A simple counted loop with trivially known range
7 define void @test1(i32) gc "statepoint-example" {
8 ; CHECK-LABEL: test1
9 ; CHECK-LABEL: entry
10 ; CHECK: statepoint
11 ; CHECK-LABEL: loop
12 ; CHECK-NOT: statepoint
13
14 entry:
15   br label %loop
16
17 loop:
18   %counter = phi i32 [ 0 , %entry ], [ %counter.inc , %loop ]
19   %counter.inc = add i32 %counter, 1
20   %counter.cmp = icmp slt i32 %counter.inc, 16
21   br i1 %counter.cmp, label %loop, label %exit
22
23 exit:
24   ret void
25 }
26
27 ; The same counted loop, but with an unknown early exit
28 define void @test2(i32) gc "statepoint-example" {
29 ; CHECK-LABEL: test2
30 ; CHECK-LABEL: entry
31 ; CHECK: statepoint
32 ; CHECK-LABEL: loop
33 ; CHECK-NOT: statepoint
34
35 entry:
36   br label %loop
37
38 loop:
39   %counter = phi i32 [ 0 , %entry ], [ %counter.inc , %continue ]
40   %counter.inc = add i32 %counter, 1
41   %counter.cmp = icmp slt i32 %counter.inc, 16
42   br i1 undef, label %continue, label %exit
43
44 continue:
45   br i1 %counter.cmp, label %loop, label %exit
46
47 exit:
48   ret void
49 }
50
51 ; The range is a 8 bit value and we can't overflow
52 define void @test3(i8 %upper) gc "statepoint-example" {
53 ; CHECK-LABEL: test3
54 ; CHECK-LABEL: entry
55 ; CHECK: statepoint
56 ; CHECK-LABEL: loop
57 ; CHECK-NOT: statepoint
58
59 entry:
60   br label %loop
61
62 loop:
63   %counter = phi i8 [ 0 , %entry ], [ %counter.inc , %loop ]
64   %counter.inc = add nsw i8 %counter, 1
65   %counter.cmp = icmp slt i8 %counter.inc, %upper
66   br i1 %counter.cmp, label %loop, label %exit
67
68 exit:
69   ret void
70 }
71
72
73 ; This function is inlined when inserting a poll.
74 declare void @do_safepoint()
75 define void @gc.safepoint_poll() {
76 ; CHECK-LABEL: gc.safepoint_poll
77 entry:
78   call void @do_safepoint()
79   ret void
80 }