1 ; RUN: llc < %s -mtriple=arm64-apple-ios7.0 -regalloc=greedy -regalloc-csr-first-time-cost=15 | FileCheck %s
3 ; This testing case is reduced from 197.parser prune_match function.
4 ; We make sure that we do not use callee-saved registers (x19 to x25).
7 ; CHECK-LABEL: prune_match:
9 ; CHECK: {{str x30|stp x29, x30}}, [sp
11 ; CHECK-NOT: stp x23, x24
12 ; CHECK-NOT: stp x21, x22
13 ; CHECK-NOT: stp x19, x20
16 ; CHECK: {{ldr x30|ldp x29, x30}}, [sp
17 ; CHECK-NOT: ldp x19, x20
18 ; CHECK-NOT: ldp x21, x22
19 ; CHECK-NOT: ldp x23, x24
22 %struct.List_o_links_struct = type { i32, i32, i32, %struct.List_o_links_struct* }
23 %struct.Connector_struct = type { i16, i16, i8, i8, %struct.Connector_struct*, i8* }
24 %struct._RuneLocale = type { [8 x i8], [32 x i8], i32 (i8*, i64, i8**)*, i32 (i32, i8*, i64, i8**)*, i32, [256 x i32], [256 x i32], [256 x i32], %struct._RuneRange, %struct._RuneRange, %struct._RuneRange, i8*, i32, i32, %struct._RuneCharClass* }
25 %struct._RuneRange = type { i32, %struct._RuneEntry* }
26 %struct._RuneEntry = type { i32, i32, i32, i32* }
27 %struct._RuneCharClass = type { [14 x i8], i32 }
28 %struct.Exp_struct = type { i8, i8, i8, i8, %union.anon }
29 %union.anon = type { %struct.E_list_struct* }
30 %struct.E_list_struct = type { %struct.E_list_struct*, %struct.Exp_struct* }
31 %struct.domain_struct = type { i8*, i32, %struct.List_o_links_struct*, i32, i32, %struct.d_tree_leaf_struct*, %struct.domain_struct* }
32 %struct.d_tree_leaf_struct = type { %struct.domain_struct*, i32, %struct.d_tree_leaf_struct* }
33 @_DefaultRuneLocale = external global %struct._RuneLocale
34 declare i32 @__maskrune(i32, i64) #7
35 define fastcc i32 @prune_match(%struct.Connector_struct* nocapture readonly %a, %struct.Connector_struct* nocapture readonly %b) #9 {
37 %label56 = bitcast %struct.Connector_struct* %a to i16*
38 %0 = load i16, i16* %label56, align 2
39 %label157 = bitcast %struct.Connector_struct* %b to i16*
40 %1 = load i16, i16* %label157, align 2
41 %cmp = icmp eq i16 %0, %1
42 br i1 %cmp, label %if.end, label %return, !prof !988
44 %priority = getelementptr inbounds %struct.Connector_struct, %struct.Connector_struct* %a, i64 0, i32 2
45 %2 = load i8, i8* %priority, align 1
46 %priority5 = getelementptr inbounds %struct.Connector_struct, %struct.Connector_struct* %b, i64 0, i32 2
47 %3 = load i8, i8* %priority5, align 1
48 %string = getelementptr inbounds %struct.Connector_struct, %struct.Connector_struct* %a, i64 0, i32 5
49 %4 = load i8*, i8** %string, align 8
50 %string7 = getelementptr inbounds %struct.Connector_struct, %struct.Connector_struct* %b, i64 0, i32 5
51 %5 = load i8*, i8** %string7, align 8
54 %lsr.iv27 = phi i64 [ %lsr.iv.next28, %if.end17 ], [ 0, %if.end ]
55 %scevgep55 = getelementptr i8, i8* %4, i64 %lsr.iv27
56 %6 = load i8, i8* %scevgep55, align 1
57 %idxprom.i.i = sext i8 %6 to i64
58 %isascii.i.i224 = icmp sgt i8 %6, -1
59 br i1 %isascii.i.i224, label %cond.true.i.i, label %cond.false.i.i, !prof !181
61 %arrayidx.i.i = getelementptr inbounds %struct._RuneLocale, %struct._RuneLocale* @_DefaultRuneLocale, i64 0, i32 5, i64 %idxprom.i.i
62 %7 = load i32, i32* %arrayidx.i.i, align 4
63 %and.i.i = and i32 %7, 32768
64 br label %isupper.exit
66 %8 = trunc i64 %idxprom.i.i to i8
67 %conv8 = sext i8 %8 to i32
68 %call3.i.i = tail call i32 @__maskrune(i32 %conv8, i64 32768) #3
69 br label %isupper.exit
71 %tobool1.sink.i.in.i = phi i32 [ %and.i.i, %cond.true.i.i ], [ %call3.i.i, %cond.false.i.i ]
72 %tobool1.sink.i.i = icmp eq i32 %tobool1.sink.i.in.i, 0
73 br i1 %tobool1.sink.i.i, label %lor.rhs, label %while.body, !prof !989
75 %sunkaddr = ptrtoint i8* %5 to i64
76 %sunkaddr58 = add i64 %sunkaddr, %lsr.iv27
77 %sunkaddr59 = inttoptr i64 %sunkaddr58 to i8*
78 %9 = load i8, i8* %sunkaddr59, align 1
79 %idxprom.i.i214 = sext i8 %9 to i64
80 %isascii.i.i213225 = icmp sgt i8 %9, -1
81 br i1 %isascii.i.i213225, label %cond.true.i.i217, label %cond.false.i.i219, !prof !181
83 %arrayidx.i.i215 = getelementptr inbounds %struct._RuneLocale, %struct._RuneLocale* @_DefaultRuneLocale, i64 0, i32 5, i64 %idxprom.i.i214
84 %10 = load i32, i32* %arrayidx.i.i215, align 4
85 %and.i.i216 = and i32 %10, 32768
86 br label %isupper.exit223
88 %11 = trunc i64 %idxprom.i.i214 to i8
89 %conv9 = sext i8 %11 to i32
90 %call3.i.i218 = tail call i32 @__maskrune(i32 %conv9, i64 32768) #3
91 br label %isupper.exit223
93 %tobool1.sink.i.in.i220 = phi i32 [ %and.i.i216, %cond.true.i.i217 ], [ %call3.i.i218, %cond.false.i.i219 ]
94 %tobool1.sink.i.i221 = icmp eq i32 %tobool1.sink.i.in.i220, 0
95 br i1 %tobool1.sink.i.i221, label %while.end, label %while.body, !prof !990
97 %sunkaddr60 = ptrtoint i8* %4 to i64
98 %sunkaddr61 = add i64 %sunkaddr60, %lsr.iv27
99 %sunkaddr62 = inttoptr i64 %sunkaddr61 to i8*
100 %12 = load i8, i8* %sunkaddr62, align 1
101 %sunkaddr63 = ptrtoint i8* %5 to i64
102 %sunkaddr64 = add i64 %sunkaddr63, %lsr.iv27
103 %sunkaddr65 = inttoptr i64 %sunkaddr64 to i8*
104 %13 = load i8, i8* %sunkaddr65, align 1
105 %cmp14 = icmp eq i8 %12, %13
106 br i1 %cmp14, label %if.end17, label %return, !prof !991
108 %lsr.iv.next28 = add i64 %lsr.iv27, 1
112 %15 = icmp eq i8 %14, 0
113 br i1 %15, label %if.then23, label %if.else88, !prof !992
115 %sunkaddr66 = ptrtoint %struct.Connector_struct* %a to i64
116 %sunkaddr67 = add i64 %sunkaddr66, 16
117 %sunkaddr68 = inttoptr i64 %sunkaddr67 to i8**
118 %16 = load i8*, i8** %sunkaddr68, align 8
119 %17 = load i8, i8* %16, align 1
120 %cmp26 = icmp eq i8 %17, 83
121 %sunkaddr69 = ptrtoint i8* %4 to i64
122 %sunkaddr70 = add i64 %sunkaddr69, %lsr.iv27
123 %sunkaddr71 = inttoptr i64 %sunkaddr70 to i8*
124 %18 = load i8, i8* %sunkaddr71, align 1
125 br i1 %cmp26, label %land.lhs.true28, label %while.cond59.preheader, !prof !993
127 switch i8 %18, label %land.rhs.preheader [
128 i8 112, label %land.lhs.true35
132 %sunkaddr72 = ptrtoint i8* %5 to i64
133 %sunkaddr73 = add i64 %sunkaddr72, %lsr.iv27
134 %sunkaddr74 = inttoptr i64 %sunkaddr73 to i8*
135 %19 = load i8, i8* %sunkaddr74, align 1
136 switch i8 %19, label %land.rhs.preheader [
137 i8 112, label %land.lhs.true43
140 %20 = ptrtoint i8* %16 to i64
142 %scevgep52 = getelementptr i8, i8* %4, i64 %21
143 %scevgep53 = getelementptr i8, i8* %scevgep52, i64 %lsr.iv27
144 %scevgep54 = getelementptr i8, i8* %scevgep53, i64 -1
145 %cmp45 = icmp eq i8* %scevgep54, null
146 br i1 %cmp45, label %return, label %lor.lhs.false47, !prof !996
148 %22 = ptrtoint i8* %16 to i64
150 %scevgep47 = getelementptr i8, i8* %4, i64 %23
151 %scevgep48 = getelementptr i8, i8* %scevgep47, i64 %lsr.iv27
152 %scevgep49 = getelementptr i8, i8* %scevgep48, i64 -2
153 %cmp50 = icmp eq i8* %scevgep49, null
154 br i1 %cmp50, label %land.lhs.true52, label %while.cond59.preheader, !prof !997
156 %sunkaddr75 = ptrtoint i8* %4 to i64
157 %sunkaddr76 = add i64 %sunkaddr75, %lsr.iv27
158 %sunkaddr77 = add i64 %sunkaddr76, -1
159 %sunkaddr78 = inttoptr i64 %sunkaddr77 to i8*
160 %24 = load i8, i8* %sunkaddr78, align 1
161 %cmp55 = icmp eq i8 %24, 73
162 %cmp61233 = icmp eq i8 %18, 0
163 %or.cond265 = or i1 %cmp55, %cmp61233
164 br i1 %or.cond265, label %return, label %land.rhs.preheader, !prof !998
165 while.cond59.preheader:
166 %cmp61233.old = icmp eq i8 %18, 0
167 br i1 %cmp61233.old, label %return, label %land.rhs.preheader, !prof !999
169 %scevgep33 = getelementptr i8, i8* %5, i64 %lsr.iv27
170 %scevgep43 = getelementptr i8, i8* %4, i64 %lsr.iv27
173 %lsr.iv = phi i64 [ 0, %land.rhs.preheader ], [ %lsr.iv.next, %if.then83 ]
174 %25 = phi i8 [ %27, %if.then83 ], [ %18, %land.rhs.preheader ]
175 %scevgep34 = getelementptr i8, i8* %scevgep33, i64 %lsr.iv
176 %26 = load i8, i8* %scevgep34, align 1
177 %cmp64 = icmp eq i8 %26, 0
178 br i1 %cmp64, label %return, label %while.body66, !prof !1000
180 %cmp68 = icmp eq i8 %25, 42
181 %cmp72 = icmp eq i8 %26, 42
182 %or.cond = or i1 %cmp68, %cmp72
183 br i1 %or.cond, label %if.then83, label %lor.lhs.false74, !prof !1001
185 %cmp77 = icmp ne i8 %25, %26
186 %cmp81 = icmp eq i8 %25, 94
187 %or.cond208 = or i1 %cmp77, %cmp81
188 br i1 %or.cond208, label %return, label %if.then83, !prof !1002
190 %scevgep44 = getelementptr i8, i8* %scevgep43, i64 %lsr.iv
191 %scevgep45 = getelementptr i8, i8* %scevgep44, i64 1
192 %27 = load i8, i8* %scevgep45, align 1
193 %cmp61 = icmp eq i8 %27, 0
194 %lsr.iv.next = add i64 %lsr.iv, 1
195 br i1 %cmp61, label %return, label %land.rhs, !prof !999
197 %cmp89 = icmp eq i8 %2, 1
198 %cmp92 = icmp eq i8 %3, 2
199 %or.cond159 = and i1 %cmp89, %cmp92
200 br i1 %or.cond159, label %while.cond95.preheader, label %if.else123, !prof !1003
201 while.cond95.preheader:
202 %sunkaddr79 = ptrtoint i8* %4 to i64
203 %sunkaddr80 = add i64 %sunkaddr79, %lsr.iv27
204 %sunkaddr81 = inttoptr i64 %sunkaddr80 to i8*
205 %28 = load i8, i8* %sunkaddr81, align 1
206 %cmp97238 = icmp eq i8 %28, 0
207 br i1 %cmp97238, label %return, label %land.rhs99.preheader, !prof !1004
208 land.rhs99.preheader:
209 %scevgep31 = getelementptr i8, i8* %5, i64 %lsr.iv27
210 %scevgep40 = getelementptr i8, i8* %4, i64 %lsr.iv27
213 %lsr.iv17 = phi i64 [ 0, %land.rhs99.preheader ], [ %lsr.iv.next18, %if.then117 ]
214 %29 = phi i8 [ %31, %if.then117 ], [ %28, %land.rhs99.preheader ]
215 %scevgep32 = getelementptr i8, i8* %scevgep31, i64 %lsr.iv17
216 %30 = load i8, i8* %scevgep32, align 1
217 %cmp101 = icmp eq i8 %30, 0
218 br i1 %cmp101, label %return, label %while.body104, !prof !1005
220 %cmp107 = icmp eq i8 %29, %30
221 %cmp111 = icmp eq i8 %29, 42
222 %or.cond209 = or i1 %cmp107, %cmp111
223 %cmp115 = icmp eq i8 %30, 94
224 %or.cond210 = or i1 %or.cond209, %cmp115
225 br i1 %or.cond210, label %if.then117, label %return, !prof !1006
227 %scevgep41 = getelementptr i8, i8* %scevgep40, i64 %lsr.iv17
228 %scevgep42 = getelementptr i8, i8* %scevgep41, i64 1
229 %31 = load i8, i8* %scevgep42, align 1
230 %cmp97 = icmp eq i8 %31, 0
231 %lsr.iv.next18 = add i64 %lsr.iv17, 1
232 br i1 %cmp97, label %return, label %land.rhs99, !prof !1004
234 %cmp124 = icmp eq i8 %3, 1
235 %cmp127 = icmp eq i8 %2, 2
236 %or.cond160 = and i1 %cmp124, %cmp127
237 br i1 %or.cond160, label %while.cond130.preheader, label %return, !prof !1007
238 while.cond130.preheader:
239 %sunkaddr82 = ptrtoint i8* %4 to i64
240 %sunkaddr83 = add i64 %sunkaddr82, %lsr.iv27
241 %sunkaddr84 = inttoptr i64 %sunkaddr83 to i8*
242 %32 = load i8, i8* %sunkaddr84, align 1
243 %cmp132244 = icmp eq i8 %32, 0
244 br i1 %cmp132244, label %return, label %land.rhs134.preheader, !prof !1008
245 land.rhs134.preheader:
246 %scevgep29 = getelementptr i8, i8* %5, i64 %lsr.iv27
247 %scevgep37 = getelementptr i8, i8* %4, i64 %lsr.iv27
248 br label %land.rhs134
250 %lsr.iv22 = phi i64 [ 0, %land.rhs134.preheader ], [ %lsr.iv.next23, %if.then152 ]
251 %33 = phi i8 [ %35, %if.then152 ], [ %32, %land.rhs134.preheader ]
252 %scevgep30 = getelementptr i8, i8* %scevgep29, i64 %lsr.iv22
253 %34 = load i8, i8* %scevgep30, align 1
254 %cmp136 = icmp eq i8 %34, 0
255 br i1 %cmp136, label %return, label %while.body139, !prof !1009
257 %cmp142 = icmp eq i8 %33, %34
258 %cmp146 = icmp eq i8 %34, 42
259 %or.cond211 = or i1 %cmp142, %cmp146
260 %cmp150 = icmp eq i8 %33, 94
261 %or.cond212 = or i1 %or.cond211, %cmp150
262 br i1 %or.cond212, label %if.then152, label %return, !prof !1010
264 %scevgep38 = getelementptr i8, i8* %scevgep37, i64 %lsr.iv22
265 %scevgep39 = getelementptr i8, i8* %scevgep38, i64 1
266 %35 = load i8, i8* %scevgep39, align 1
267 %cmp132 = icmp eq i8 %35, 0
268 %lsr.iv.next23 = add i64 %lsr.iv22, 1
269 br i1 %cmp132, label %return, label %land.rhs134, !prof !1008
271 %retval.0 = phi i32 [ 0, %entry ], [ 1, %land.lhs.true52 ], [ 1, %land.lhs.true43 ], [ 0, %if.else123 ], [ 1, %while.cond59.preheader ], [ 1, %while.cond95.preheader ], [ 1, %while.cond130.preheader ], [ 1, %land.lhs.true28 ], [ 1, %if.then83 ], [ 0, %lor.lhs.false74 ], [ 1, %land.rhs ], [ 1, %if.then117 ], [ 0, %while.body104 ], [ 1, %land.rhs99 ], [ 1, %if.then152 ], [ 0, %while.body139 ], [ 1, %land.rhs134 ], [ 0, %while.body ]
274 !181 = !{!"branch_weights", i32 662038, i32 1}
275 !988 = !{!"branch_weights", i32 12091450, i32 1916}
276 !989 = !{!"branch_weights", i32 7564670, i32 4526781}
277 !990 = !{!"branch_weights", i32 7484958, i32 13283499}
278 !991 = !{!"branch_weights", i32 8677007, i32 4606493}
279 !992 = !{!"branch_weights", i32 -1172426948, i32 145094705}
280 !993 = !{!"branch_weights", i32 1468914, i32 5683688}
281 !994 = !{!"branch_weights", i32 114025221, i32 -1217548794, i32 -1199521551}
282 !995 = !{!"branch_weights", i32 1853716452, i32 -444717951}
283 !996 = !{!"branch_weights", i32 1004870, i32 20259}
284 !997 = !{!"branch_weights", i32 20071, i32 189}
285 !998 = !{!"branch_weights", i32 -1020255939, i32 572177766}
286 !999 = !{!"branch_weights", i32 2666513, i32 3466431}
287 !1000 = !{!"branch_weights", i32 5117635, i32 1859780}
288 !1001 = !{!"branch_weights", i32 354902465, i32 -1444604407}
289 !1002 = !{!"branch_weights", i32 -1762419279, i32 1592770684}
290 !1003 = !{!"branch_weights", i32 1435905930, i32 -1951930624}
291 !1004 = !{!"branch_weights", i32 1, i32 504888}
292 !1005 = !{!"branch_weights", i32 94662, i32 504888}
293 !1006 = !{!"branch_weights", i32 -1897793104, i32 160196332}
294 !1007 = !{!"branch_weights", i32 2074643678, i32 -29579071}
295 !1008 = !{!"branch_weights", i32 1, i32 226163}
296 !1009 = !{!"branch_weights", i32 58357, i32 226163}
297 !1010 = !{!"branch_weights", i32 -2072848646, i32 92907517}