]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/Inline/AArch64/switch.ll
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / Transforms / Inline / AArch64 / switch.ll
1 ; RUN: opt < %s -inline -inline-threshold=20 -S -mtriple=aarch64-none-linux  | FileCheck %s
2 ; RUN: opt < %s -passes='cgscc(inline)' -inline-threshold=20 -S -mtriple=aarch64-none-linux | FileCheck %s
3
4 define i32 @callee_range(i32 %a, i32* %P) {
5   switch i32 %a, label %sw.default [
6     i32 0, label %sw.bb0
7     i32 1000, label %sw.bb1
8     i32 2000, label %sw.bb1
9     i32 3000, label %sw.bb1
10     i32 4000, label %sw.bb1
11     i32 5000, label %sw.bb1
12     i32 6000, label %sw.bb1
13     i32 7000, label %sw.bb1
14     i32 8000, label %sw.bb1
15     i32 9000, label %sw.bb1
16   ]
17
18 sw.default:
19   store volatile i32 %a, i32* %P
20   br label %return
21 sw.bb0:
22   store volatile i32 %a, i32* %P
23   br label %return
24 sw.bb1:
25   store volatile i32 %a, i32* %P
26   br label %return
27 return:
28   ret i32 42
29 }
30
31 define i32 @caller_range(i32 %a, i32* %P) {
32 ; CHECK-LABEL: @caller_range(
33 ; CHECK: call i32 @callee_range
34   %r = call i32 @callee_range(i32 %a, i32* %P)
35   ret i32 %r
36 }
37
38 define i32 @callee_bittest(i32 %a, i32* %P) {
39   switch i32 %a, label %sw.default [
40     i32 0, label %sw.bb0
41     i32 1, label %sw.bb1
42     i32 2, label %sw.bb2
43     i32 3, label %sw.bb0
44     i32 4, label %sw.bb1
45     i32 5, label %sw.bb2
46     i32 6, label %sw.bb0
47     i32 7, label %sw.bb1
48     i32 8, label %sw.bb2
49   ]
50
51 sw.default:
52   store volatile i32 %a, i32* %P
53   br label %return
54
55 sw.bb0:
56   store volatile i32 %a, i32* %P
57   br label %return
58
59 sw.bb1:
60   store volatile i32 %a, i32* %P
61   br label %return
62
63 sw.bb2:
64   br label %return
65
66 return:
67   ret i32 42
68 }
69
70
71 define i32 @caller_bittest(i32 %a, i32* %P) {
72 ; CHECK-LABEL: @caller_bittest(
73 ; CHECK-NOT: call i32 @callee_bittest
74   %r= call i32 @callee_bittest(i32 %a, i32* %P)
75   ret i32 %r
76 }
77
78 define i32 @callee_jumptable(i32 %a, i32* %P) {
79   switch i32 %a, label %sw.default [
80     i32 1001, label %sw.bb101
81     i32 1002, label %sw.bb102
82     i32 1003, label %sw.bb103
83     i32 1004, label %sw.bb104
84     i32 1005, label %sw.bb101
85     i32 1006, label %sw.bb102
86     i32 1007, label %sw.bb103
87     i32 1008, label %sw.bb104
88     i32 1009, label %sw.bb101
89     i32 1010, label %sw.bb102
90     i32 1011, label %sw.bb103
91     i32 1012, label %sw.bb104
92  ]
93
94 sw.default:
95   br label %return
96
97 sw.bb101:
98   store volatile i32 %a, i32* %P
99   br label %return
100
101 sw.bb102:
102   store volatile i32 %a, i32* %P
103   br label %return
104
105 sw.bb103:
106   store volatile i32 %a, i32* %P
107   br label %return
108
109 sw.bb104:
110   store volatile i32 %a, i32* %P
111   br label %return
112
113 return:
114   ret i32 42
115 }
116
117 define i32 @caller_jumptable(i32 %a, i32 %b, i32* %P) {
118 ; CHECK-LABEL: @caller_jumptable(
119 ; CHECK: call i32 @callee_jumptable
120   %r = call i32 @callee_jumptable(i32 %b, i32* %P)
121   ret i32 %r
122 }
123
124
125 define internal i32 @callee_negativeCost(i32 %t)  {
126 entry:
127   switch i32 %t, label %sw.default [
128     i32 1, label %sw.bb
129     i32 0, label %sw.bb1
130     i32 42, label %sw.bb2
131     i32 43, label %sw.bb3
132   ]
133
134 sw.bb:                                            ; preds = %entry
135   br label %cleanup
136
137 sw.bb1:                                           ; preds = %entry
138   br label %cleanup
139
140 sw.bb2:                                           ; preds = %entry
141   br label %cleanup
142
143 sw.bb3:                                           ; preds = %entry
144   br label %cleanup
145
146 sw.default:                                       ; preds = %entry
147   br label %cleanup
148
149 cleanup:                                          ; preds = %sw.default, %sw.bb3, %sw.bb2, %sw.bb1, %sw.bb
150   %retval.0 = phi i32 [ 1, %sw.default ], [ 3, %sw.bb3 ], [ 2, %sw.bb2 ], [ 0, %sw.bb1 ], [ 0, %sw.bb ]
151   ret i32 %retval.0
152 }
153
154 define i32 @caller_negativeCost(i32 %t) {
155 ; CHECK-LABEL: @caller_negativeCost(
156 ; CHECK-NOT: call i32 @callee_negativeCost
157 entry:
158   %call = call i32 @callee_negativeCost(i32 %t)
159   ret i32 %call
160 }