x86 FP atomic codegen: don't drop globals, stack
[oota-llvm.git] / test / Transforms / SimplifyCFG / fast-fallthrough.ll
1 ; RUN: opt -S %s -simplifycfg | FileCheck %s
2
3 define void @test(i32 %length.i, i32 %i) {
4 ; CHECK-LABEL: @test
5   %iplus1 = add nsw i32 %i, 1
6   %var29 = icmp slt i32 %i, %length.i
7   %var30 = icmp slt i32 %iplus1, %length.i
8 ; CHECK: br i1 %var30, label %in_bounds, label %next
9   br i1 %var29, label %next, label %out_of_bounds, !prof !{!"branch_weights", i32 1000, i32 0}
10
11 next:
12 ; CHECK-LABEL: next:
13 ; CHECK: br i1 %var29, label %out_of_bounds2, label %out_of_bounds
14   br i1 %var30, label %in_bounds, label %out_of_bounds2, !prof !{!"branch_weights", i32 1000, i32 0}
15
16 in_bounds:
17   ret void
18
19 out_of_bounds:
20   call void @foo(i64 0)
21   unreachable
22
23 out_of_bounds2:
24   call void @foo(i64 1)
25   unreachable
26 }
27
28 define void @test2(i32 %length.i, i32 %i) {
29 ; CHECK-LABEL: @test2
30   %var29 = icmp slt i32 %i, %length.i
31 ; CHECK: br i1 %var30, label %in_bounds, label %next
32   br i1 %var29, label %next, label %out_of_bounds, !prof !{!"branch_weights", i32 1000, i32 0}
33
34 next:
35 ; CHECK-LABEL: next:
36 ; CHECK: br i1 %var29, label %out_of_bounds2, label %out_of_bounds
37   %iplus1 = add nsw i32 %i, 1
38   %var30 = icmp slt i32 %iplus1, %length.i
39   br i1 %var30, label %in_bounds, label %out_of_bounds2, !prof !{!"branch_weights", i32 1000, i32 0}
40
41 in_bounds:
42   ret void
43
44 out_of_bounds:
45   call void @foo(i64 0)
46   unreachable
47
48 out_of_bounds2:
49   call void @foo(i64 1)
50   unreachable
51 }
52
53 ; As written, this one can't trigger today.  It would require us to duplicate
54 ; the %val1 load down two paths and that's not implemented yet.
55 define i64 @test3(i32 %length.i, i32 %i, i64* %base) {
56 ; CHECK-LABEL: @test3
57   %var29 = icmp slt i32 %i, %length.i
58 ; CHECK: br i1 %var29, label %next, label %out_of_bounds
59   br i1 %var29, label %next, label %out_of_bounds, !prof !{!"branch_weights", i32 1000, i32 0}
60
61 next:
62 ; CHECK-LABEL: next:
63   %addr1 = getelementptr i64, i64* %base, i32 %i
64   %val1 = load i64, i64* %addr1
65   %iplus1 = add nsw i32 %i, 1
66   %var30 = icmp slt i32 %iplus1, %length.i
67 ; CHECK: br i1 %var30, label %in_bounds, label %out_of_bounds2
68   br i1 %var30, label %in_bounds, label %out_of_bounds2, !prof !{!"branch_weights", i32 1000, i32 0}
69
70 in_bounds:
71   %addr2 = getelementptr i64, i64* %base, i32 %iplus1
72   %val2 = load i64, i64* %addr2
73   %res = sub i64 %val1, %val2
74   ret i64 %res
75
76 out_of_bounds:
77   call void @foo(i64 0)
78   unreachable
79
80 out_of_bounds2:
81   call void @foo(i64 %val1)
82   unreachable
83 }
84
85 declare void @foo(i64)
86