1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc %s -o - -mtriple=m68k -mcpu=M68000 -verify-machineinstrs | FileCheck %s --check-prefix=NO-ATOMIC
3 ; RUN: llc %s -o - -mtriple=m68k -mcpu=M68010 -verify-machineinstrs | FileCheck %s --check-prefix=NO-ATOMIC
4 ; RUN: llc %s -o - -mtriple=m68k -mcpu=M68020 -verify-machineinstrs | FileCheck %s --check-prefix=ATOMIC
5 ; RUN: llc %s -o - -mtriple=m68k -mcpu=M68030 -verify-machineinstrs | FileCheck %s --check-prefix=ATOMIC
6 ; RUN: llc %s -o - -mtriple=m68k -mcpu=M68040 -verify-machineinstrs | FileCheck %s --check-prefix=ATOMIC
8 define i8 @atomicrmw_add_i8(i8 %val, ptr %ptr) {
9 ; NO-ATOMIC-LABEL: atomicrmw_add_i8:
10 ; NO-ATOMIC: .cfi_startproc
11 ; NO-ATOMIC-NEXT: ; %bb.0:
12 ; NO-ATOMIC-NEXT: suba.l #12, %sp
13 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
14 ; NO-ATOMIC-NEXT: move.b (19,%sp), %d0
15 ; NO-ATOMIC-NEXT: and.l #255, %d0
16 ; NO-ATOMIC-NEXT: move.l %d0, (4,%sp)
17 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
18 ; NO-ATOMIC-NEXT: jsr __sync_fetch_and_add_1@PLT
19 ; NO-ATOMIC-NEXT: adda.l #12, %sp
22 ; ATOMIC-LABEL: atomicrmw_add_i8:
23 ; ATOMIC: .cfi_startproc
24 ; ATOMIC-NEXT: ; %bb.0:
25 ; ATOMIC-NEXT: suba.l #8, %sp
26 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
27 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
28 ; ATOMIC-NEXT: move.b (15,%sp), %d1
29 ; ATOMIC-NEXT: move.l (16,%sp), %a0
30 ; ATOMIC-NEXT: move.b (%a0), %d2
31 ; ATOMIC-NEXT: move.b %d2, %d0
32 ; ATOMIC-NEXT: .LBB0_1: ; %atomicrmw.start
33 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
34 ; ATOMIC-NEXT: move.b %d2, %d3
35 ; ATOMIC-NEXT: add.b %d1, %d3
36 ; ATOMIC-NEXT: cas.b %d0, %d3, (%a0)
37 ; ATOMIC-NEXT: move.b %d0, %d3
38 ; ATOMIC-NEXT: sub.b %d2, %d3
39 ; ATOMIC-NEXT: seq %d2
40 ; ATOMIC-NEXT: sub.b #1, %d2
41 ; ATOMIC-NEXT: move.b %d0, %d2
42 ; ATOMIC-NEXT: bne .LBB0_1
43 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.end
44 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
45 ; ATOMIC-NEXT: adda.l #8, %sp
47 %old = atomicrmw add ptr %ptr, i8 %val monotonic
51 define i16 @atomicrmw_sub_i16(i16 %val, ptr %ptr) {
52 ; NO-ATOMIC-LABEL: atomicrmw_sub_i16:
53 ; NO-ATOMIC: .cfi_startproc
54 ; NO-ATOMIC-NEXT: ; %bb.0:
55 ; NO-ATOMIC-NEXT: suba.l #12, %sp
56 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
57 ; NO-ATOMIC-NEXT: move.w (18,%sp), %d0
58 ; NO-ATOMIC-NEXT: and.l #65535, %d0
59 ; NO-ATOMIC-NEXT: move.l %d0, (4,%sp)
60 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
61 ; NO-ATOMIC-NEXT: jsr __sync_fetch_and_sub_2@PLT
62 ; NO-ATOMIC-NEXT: adda.l #12, %sp
65 ; ATOMIC-LABEL: atomicrmw_sub_i16:
66 ; ATOMIC: .cfi_startproc
67 ; ATOMIC-NEXT: ; %bb.0:
68 ; ATOMIC-NEXT: suba.l #8, %sp
69 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
70 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
71 ; ATOMIC-NEXT: move.w (14,%sp), %d1
72 ; ATOMIC-NEXT: move.l (16,%sp), %a0
73 ; ATOMIC-NEXT: move.w (%a0), %d2
74 ; ATOMIC-NEXT: move.w %d2, %d0
75 ; ATOMIC-NEXT: .LBB1_1: ; %atomicrmw.start
76 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
77 ; ATOMIC-NEXT: move.w %d2, %d3
78 ; ATOMIC-NEXT: sub.w %d1, %d3
79 ; ATOMIC-NEXT: cas.w %d0, %d3, (%a0)
80 ; ATOMIC-NEXT: move.w %d0, %d3
81 ; ATOMIC-NEXT: sub.w %d2, %d3
82 ; ATOMIC-NEXT: seq %d2
83 ; ATOMIC-NEXT: sub.b #1, %d2
84 ; ATOMIC-NEXT: move.w %d0, %d2
85 ; ATOMIC-NEXT: bne .LBB1_1
86 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.end
87 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
88 ; ATOMIC-NEXT: adda.l #8, %sp
90 %old = atomicrmw sub ptr %ptr, i16 %val acquire
94 define i32 @atomicrmw_and_i32(i32 %val, ptr %ptr) {
95 ; NO-ATOMIC-LABEL: atomicrmw_and_i32:
96 ; NO-ATOMIC: .cfi_startproc
97 ; NO-ATOMIC-NEXT: ; %bb.0:
98 ; NO-ATOMIC-NEXT: suba.l #12, %sp
99 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
100 ; NO-ATOMIC-NEXT: move.l (16,%sp), (4,%sp)
101 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
102 ; NO-ATOMIC-NEXT: jsr __sync_fetch_and_and_4@PLT
103 ; NO-ATOMIC-NEXT: adda.l #12, %sp
104 ; NO-ATOMIC-NEXT: rts
106 ; ATOMIC-LABEL: atomicrmw_and_i32:
107 ; ATOMIC: .cfi_startproc
108 ; ATOMIC-NEXT: ; %bb.0:
109 ; ATOMIC-NEXT: suba.l #8, %sp
110 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
111 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
112 ; ATOMIC-NEXT: move.l (12,%sp), %d1
113 ; ATOMIC-NEXT: move.l (16,%sp), %a0
114 ; ATOMIC-NEXT: move.l (%a0), %d2
115 ; ATOMIC-NEXT: move.l %d2, %d0
116 ; ATOMIC-NEXT: .LBB2_1: ; %atomicrmw.start
117 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
118 ; ATOMIC-NEXT: move.l %d2, %d3
119 ; ATOMIC-NEXT: and.l %d1, %d3
120 ; ATOMIC-NEXT: cas.l %d0, %d3, (%a0)
121 ; ATOMIC-NEXT: move.l %d0, %d3
122 ; ATOMIC-NEXT: sub.l %d2, %d3
123 ; ATOMIC-NEXT: seq %d2
124 ; ATOMIC-NEXT: sub.b #1, %d2
125 ; ATOMIC-NEXT: move.l %d0, %d2
126 ; ATOMIC-NEXT: bne .LBB2_1
127 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.end
128 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
129 ; ATOMIC-NEXT: adda.l #8, %sp
131 %old = atomicrmw and ptr %ptr, i32 %val seq_cst
135 define i64 @atomicrmw_xor_i64(i64 %val, ptr %ptr) {
136 ; NO-ATOMIC-LABEL: atomicrmw_xor_i64:
137 ; NO-ATOMIC: .cfi_startproc
138 ; NO-ATOMIC-NEXT: ; %bb.0:
139 ; NO-ATOMIC-NEXT: suba.l #20, %sp
140 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -24
141 ; NO-ATOMIC-NEXT: move.l #3, (12,%sp)
142 ; NO-ATOMIC-NEXT: move.l (28,%sp), (8,%sp)
143 ; NO-ATOMIC-NEXT: move.l (24,%sp), (4,%sp)
144 ; NO-ATOMIC-NEXT: move.l (32,%sp), (%sp)
145 ; NO-ATOMIC-NEXT: jsr __atomic_fetch_xor_8@PLT
146 ; NO-ATOMIC-NEXT: adda.l #20, %sp
147 ; NO-ATOMIC-NEXT: rts
149 ; ATOMIC-LABEL: atomicrmw_xor_i64:
150 ; ATOMIC: .cfi_startproc
151 ; ATOMIC-NEXT: ; %bb.0:
152 ; ATOMIC-NEXT: suba.l #20, %sp
153 ; ATOMIC-NEXT: .cfi_def_cfa_offset -24
154 ; ATOMIC-NEXT: move.l #3, (12,%sp)
155 ; ATOMIC-NEXT: move.l (28,%sp), (8,%sp)
156 ; ATOMIC-NEXT: move.l (24,%sp), (4,%sp)
157 ; ATOMIC-NEXT: move.l (32,%sp), (%sp)
158 ; ATOMIC-NEXT: jsr __atomic_fetch_xor_8@PLT
159 ; ATOMIC-NEXT: adda.l #20, %sp
161 %old = atomicrmw xor ptr %ptr, i64 %val release
165 define i8 @atomicrmw_or_i8(i8 %val, ptr %ptr) {
166 ; NO-ATOMIC-LABEL: atomicrmw_or_i8:
167 ; NO-ATOMIC: .cfi_startproc
168 ; NO-ATOMIC-NEXT: ; %bb.0:
169 ; NO-ATOMIC-NEXT: suba.l #12, %sp
170 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
171 ; NO-ATOMIC-NEXT: move.b (19,%sp), %d0
172 ; NO-ATOMIC-NEXT: and.l #255, %d0
173 ; NO-ATOMIC-NEXT: move.l %d0, (4,%sp)
174 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
175 ; NO-ATOMIC-NEXT: jsr __sync_fetch_and_or_1@PLT
176 ; NO-ATOMIC-NEXT: adda.l #12, %sp
177 ; NO-ATOMIC-NEXT: rts
179 ; ATOMIC-LABEL: atomicrmw_or_i8:
180 ; ATOMIC: .cfi_startproc
181 ; ATOMIC-NEXT: ; %bb.0:
182 ; ATOMIC-NEXT: suba.l #8, %sp
183 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
184 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
185 ; ATOMIC-NEXT: move.b (15,%sp), %d1
186 ; ATOMIC-NEXT: move.l (16,%sp), %a0
187 ; ATOMIC-NEXT: move.b (%a0), %d2
188 ; ATOMIC-NEXT: move.b %d2, %d0
189 ; ATOMIC-NEXT: .LBB4_1: ; %atomicrmw.start
190 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
191 ; ATOMIC-NEXT: move.b %d2, %d3
192 ; ATOMIC-NEXT: or.b %d1, %d3
193 ; ATOMIC-NEXT: cas.b %d0, %d3, (%a0)
194 ; ATOMIC-NEXT: move.b %d0, %d3
195 ; ATOMIC-NEXT: sub.b %d2, %d3
196 ; ATOMIC-NEXT: seq %d2
197 ; ATOMIC-NEXT: sub.b #1, %d2
198 ; ATOMIC-NEXT: move.b %d0, %d2
199 ; ATOMIC-NEXT: bne .LBB4_1
200 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.end
201 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
202 ; ATOMIC-NEXT: adda.l #8, %sp
204 %old = atomicrmw or ptr %ptr, i8 %val monotonic
208 define i16 @atmoicrmw_nand_i16(i16 %val, ptr %ptr) {
209 ; NO-ATOMIC-LABEL: atmoicrmw_nand_i16:
210 ; NO-ATOMIC: .cfi_startproc
211 ; NO-ATOMIC-NEXT: ; %bb.0:
212 ; NO-ATOMIC-NEXT: suba.l #12, %sp
213 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
214 ; NO-ATOMIC-NEXT: movem.l %d2, (8,%sp) ; 8-byte Folded Spill
215 ; NO-ATOMIC-NEXT: move.w (18,%sp), %d2
216 ; NO-ATOMIC-NEXT: move.l %d2, %d0
217 ; NO-ATOMIC-NEXT: and.l #65535, %d0
218 ; NO-ATOMIC-NEXT: move.l %d0, (4,%sp)
219 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
220 ; NO-ATOMIC-NEXT: jsr __sync_fetch_and_nand_2@PLT
221 ; NO-ATOMIC-NEXT: move.w %d2, %d0
222 ; NO-ATOMIC-NEXT: movem.l (8,%sp), %d2 ; 8-byte Folded Reload
223 ; NO-ATOMIC-NEXT: adda.l #12, %sp
224 ; NO-ATOMIC-NEXT: rts
226 ; ATOMIC-LABEL: atmoicrmw_nand_i16:
227 ; ATOMIC: .cfi_startproc
228 ; ATOMIC-NEXT: ; %bb.0:
229 ; ATOMIC-NEXT: suba.l #8, %sp
230 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
231 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
232 ; ATOMIC-NEXT: move.w (14,%sp), %d0
233 ; ATOMIC-NEXT: move.l (16,%sp), %a0
234 ; ATOMIC-NEXT: move.w (%a0), %d2
235 ; ATOMIC-NEXT: move.w %d2, %d1
236 ; ATOMIC-NEXT: .LBB5_1: ; %atomicrmw.start
237 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
238 ; ATOMIC-NEXT: move.w %d2, %d3
239 ; ATOMIC-NEXT: and.w %d0, %d3
240 ; ATOMIC-NEXT: eori.w #-1, %d3
241 ; ATOMIC-NEXT: cas.w %d1, %d3, (%a0)
242 ; ATOMIC-NEXT: move.w %d1, %d3
243 ; ATOMIC-NEXT: sub.w %d2, %d3
244 ; ATOMIC-NEXT: seq %d2
245 ; ATOMIC-NEXT: sub.b #1, %d2
246 ; ATOMIC-NEXT: move.w %d1, %d2
247 ; ATOMIC-NEXT: bne .LBB5_1
248 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.end
249 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
250 ; ATOMIC-NEXT: adda.l #8, %sp
252 %old = atomicrmw nand ptr %ptr, i16 %val seq_cst
256 define i32 @atomicrmw_min_i32(i32 %val, ptr %ptr) {
257 ; NO-ATOMIC-LABEL: atomicrmw_min_i32:
258 ; NO-ATOMIC: .cfi_startproc
259 ; NO-ATOMIC-NEXT: ; %bb.0:
260 ; NO-ATOMIC-NEXT: suba.l #12, %sp
261 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
262 ; NO-ATOMIC-NEXT: move.l (16,%sp), (4,%sp)
263 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
264 ; NO-ATOMIC-NEXT: jsr __sync_fetch_and_min_4@PLT
265 ; NO-ATOMIC-NEXT: adda.l #12, %sp
266 ; NO-ATOMIC-NEXT: rts
268 ; ATOMIC-LABEL: atomicrmw_min_i32:
269 ; ATOMIC: .cfi_startproc
270 ; ATOMIC-NEXT: ; %bb.0:
271 ; ATOMIC-NEXT: suba.l #8, %sp
272 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
273 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
274 ; ATOMIC-NEXT: move.l (12,%sp), %d1
275 ; ATOMIC-NEXT: move.l (16,%sp), %a0
276 ; ATOMIC-NEXT: move.l (%a0), %d2
277 ; ATOMIC-NEXT: bra .LBB6_1
278 ; ATOMIC-NEXT: .LBB6_3: ; %atomicrmw.start
279 ; ATOMIC-NEXT: ; in Loop: Header=BB6_1 Depth=1
280 ; ATOMIC-NEXT: move.l %d2, %d0
281 ; ATOMIC-NEXT: cas.l %d0, %d3, (%a0)
282 ; ATOMIC-NEXT: move.l %d0, %d3
283 ; ATOMIC-NEXT: sub.l %d2, %d3
284 ; ATOMIC-NEXT: seq %d2
285 ; ATOMIC-NEXT: sub.b #1, %d2
286 ; ATOMIC-NEXT: move.l %d0, %d2
287 ; ATOMIC-NEXT: beq .LBB6_4
288 ; ATOMIC-NEXT: .LBB6_1: ; %atomicrmw.start
289 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
290 ; ATOMIC-NEXT: move.l %d2, %d0
291 ; ATOMIC-NEXT: sub.l %d1, %d0
292 ; ATOMIC-NEXT: move.l %d2, %d3
293 ; ATOMIC-NEXT: ble .LBB6_3
294 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.start
295 ; ATOMIC-NEXT: ; in Loop: Header=BB6_1 Depth=1
296 ; ATOMIC-NEXT: move.l %d1, %d3
297 ; ATOMIC-NEXT: bra .LBB6_3
298 ; ATOMIC-NEXT: .LBB6_4: ; %atomicrmw.end
299 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
300 ; ATOMIC-NEXT: adda.l #8, %sp
302 %old = atomicrmw min ptr %ptr, i32 %val acquire
306 define i64 @atomicrmw_max_i64(i64 %val, ptr %ptr) {
307 ; NO-ATOMIC-LABEL: atomicrmw_max_i64:
308 ; NO-ATOMIC: .cfi_startproc
309 ; NO-ATOMIC-NEXT: ; %bb.0:
310 ; NO-ATOMIC-NEXT: suba.l #52, %sp
311 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -56
312 ; NO-ATOMIC-NEXT: movem.l %d2-%d4/%a2-%a3, (32,%sp) ; 24-byte Folded Spill
313 ; NO-ATOMIC-NEXT: move.l (60,%sp), %d3
314 ; NO-ATOMIC-NEXT: move.l (56,%sp), %d4
315 ; NO-ATOMIC-NEXT: move.l (64,%sp), %a2
316 ; NO-ATOMIC-NEXT: move.l (4,%a2), %d1
317 ; NO-ATOMIC-NEXT: move.l (%a2), %d0
318 ; NO-ATOMIC-NEXT: lea (24,%sp), %a3
319 ; NO-ATOMIC-NEXT: bra .LBB7_1
320 ; NO-ATOMIC-NEXT: .LBB7_3: ; %atomicrmw.start
321 ; NO-ATOMIC-NEXT: ; in Loop: Header=BB7_1 Depth=1
322 ; NO-ATOMIC-NEXT: move.l %d1, (12,%sp)
323 ; NO-ATOMIC-NEXT: move.l %d0, (8,%sp)
324 ; NO-ATOMIC-NEXT: move.l #5, (20,%sp)
325 ; NO-ATOMIC-NEXT: move.l #5, (16,%sp)
326 ; NO-ATOMIC-NEXT: jsr __atomic_compare_exchange_8@PLT
327 ; NO-ATOMIC-NEXT: move.b %d0, %d2
328 ; NO-ATOMIC-NEXT: move.l (28,%sp), %d1
329 ; NO-ATOMIC-NEXT: move.l (24,%sp), %d0
330 ; NO-ATOMIC-NEXT: cmpi.b #0, %d2
331 ; NO-ATOMIC-NEXT: bne .LBB7_4
332 ; NO-ATOMIC-NEXT: .LBB7_1: ; %atomicrmw.start
333 ; NO-ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
334 ; NO-ATOMIC-NEXT: move.l %d0, (24,%sp)
335 ; NO-ATOMIC-NEXT: move.l %d1, (28,%sp)
336 ; NO-ATOMIC-NEXT: move.l %a2, (%sp)
337 ; NO-ATOMIC-NEXT: move.l %a3, (4,%sp)
338 ; NO-ATOMIC-NEXT: move.l %d3, %d2
339 ; NO-ATOMIC-NEXT: sub.l %d1, %d2
340 ; NO-ATOMIC-NEXT: move.l %d4, %d2
341 ; NO-ATOMIC-NEXT: subx.l %d0, %d2
342 ; NO-ATOMIC-NEXT: slt %d2
343 ; NO-ATOMIC-NEXT: cmpi.b #0, %d2
344 ; NO-ATOMIC-NEXT: bne .LBB7_3
345 ; NO-ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.start
346 ; NO-ATOMIC-NEXT: ; in Loop: Header=BB7_1 Depth=1
347 ; NO-ATOMIC-NEXT: move.l %d3, %d1
348 ; NO-ATOMIC-NEXT: move.l %d4, %d0
349 ; NO-ATOMIC-NEXT: bra .LBB7_3
350 ; NO-ATOMIC-NEXT: .LBB7_4: ; %atomicrmw.end
351 ; NO-ATOMIC-NEXT: movem.l (32,%sp), %d2-%d4/%a2-%a3 ; 24-byte Folded Reload
352 ; NO-ATOMIC-NEXT: adda.l #52, %sp
353 ; NO-ATOMIC-NEXT: rts
355 ; ATOMIC-LABEL: atomicrmw_max_i64:
356 ; ATOMIC: .cfi_startproc
357 ; ATOMIC-NEXT: ; %bb.0:
358 ; ATOMIC-NEXT: suba.l #52, %sp
359 ; ATOMIC-NEXT: .cfi_def_cfa_offset -56
360 ; ATOMIC-NEXT: movem.l %d2-%d4/%a2-%a3, (32,%sp) ; 24-byte Folded Spill
361 ; ATOMIC-NEXT: move.l (60,%sp), %d3
362 ; ATOMIC-NEXT: move.l (56,%sp), %d4
363 ; ATOMIC-NEXT: move.l (64,%sp), %a2
364 ; ATOMIC-NEXT: move.l (4,%a2), %d1
365 ; ATOMIC-NEXT: move.l (%a2), %d0
366 ; ATOMIC-NEXT: lea (24,%sp), %a3
367 ; ATOMIC-NEXT: bra .LBB7_1
368 ; ATOMIC-NEXT: .LBB7_3: ; %atomicrmw.start
369 ; ATOMIC-NEXT: ; in Loop: Header=BB7_1 Depth=1
370 ; ATOMIC-NEXT: move.l %d1, (12,%sp)
371 ; ATOMIC-NEXT: move.l %d0, (8,%sp)
372 ; ATOMIC-NEXT: move.l #5, (20,%sp)
373 ; ATOMIC-NEXT: move.l #5, (16,%sp)
374 ; ATOMIC-NEXT: jsr __atomic_compare_exchange_8@PLT
375 ; ATOMIC-NEXT: move.b %d0, %d2
376 ; ATOMIC-NEXT: move.l (28,%sp), %d1
377 ; ATOMIC-NEXT: move.l (24,%sp), %d0
378 ; ATOMIC-NEXT: cmpi.b #0, %d2
379 ; ATOMIC-NEXT: bne .LBB7_4
380 ; ATOMIC-NEXT: .LBB7_1: ; %atomicrmw.start
381 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
382 ; ATOMIC-NEXT: move.l %d0, (24,%sp)
383 ; ATOMIC-NEXT: move.l %d1, (28,%sp)
384 ; ATOMIC-NEXT: move.l %a2, (%sp)
385 ; ATOMIC-NEXT: move.l %a3, (4,%sp)
386 ; ATOMIC-NEXT: move.l %d3, %d2
387 ; ATOMIC-NEXT: sub.l %d1, %d2
388 ; ATOMIC-NEXT: move.l %d4, %d2
389 ; ATOMIC-NEXT: subx.l %d0, %d2
390 ; ATOMIC-NEXT: slt %d2
391 ; ATOMIC-NEXT: cmpi.b #0, %d2
392 ; ATOMIC-NEXT: bne .LBB7_3
393 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.start
394 ; ATOMIC-NEXT: ; in Loop: Header=BB7_1 Depth=1
395 ; ATOMIC-NEXT: move.l %d3, %d1
396 ; ATOMIC-NEXT: move.l %d4, %d0
397 ; ATOMIC-NEXT: bra .LBB7_3
398 ; ATOMIC-NEXT: .LBB7_4: ; %atomicrmw.end
399 ; ATOMIC-NEXT: movem.l (32,%sp), %d2-%d4/%a2-%a3 ; 24-byte Folded Reload
400 ; ATOMIC-NEXT: adda.l #52, %sp
402 %old = atomicrmw max ptr %ptr, i64 %val seq_cst
406 define i8 @atomicrmw_i8_umin(i8 %val, ptr %ptr) {
407 ; NO-ATOMIC-LABEL: atomicrmw_i8_umin:
408 ; NO-ATOMIC: .cfi_startproc
409 ; NO-ATOMIC-NEXT: ; %bb.0:
410 ; NO-ATOMIC-NEXT: suba.l #12, %sp
411 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
412 ; NO-ATOMIC-NEXT: move.b (19,%sp), %d0
413 ; NO-ATOMIC-NEXT: and.l #255, %d0
414 ; NO-ATOMIC-NEXT: move.l %d0, (4,%sp)
415 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
416 ; NO-ATOMIC-NEXT: jsr __sync_fetch_and_umin_1@PLT
417 ; NO-ATOMIC-NEXT: adda.l #12, %sp
418 ; NO-ATOMIC-NEXT: rts
420 ; ATOMIC-LABEL: atomicrmw_i8_umin:
421 ; ATOMIC: .cfi_startproc
422 ; ATOMIC-NEXT: ; %bb.0:
423 ; ATOMIC-NEXT: suba.l #8, %sp
424 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
425 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
426 ; ATOMIC-NEXT: move.b (15,%sp), %d1
427 ; ATOMIC-NEXT: move.l (16,%sp), %a0
428 ; ATOMIC-NEXT: move.b (%a0), %d2
429 ; ATOMIC-NEXT: bra .LBB8_1
430 ; ATOMIC-NEXT: .LBB8_3: ; %atomicrmw.start
431 ; ATOMIC-NEXT: ; in Loop: Header=BB8_1 Depth=1
432 ; ATOMIC-NEXT: move.b %d2, %d0
433 ; ATOMIC-NEXT: cas.b %d0, %d3, (%a0)
434 ; ATOMIC-NEXT: move.b %d0, %d3
435 ; ATOMIC-NEXT: sub.b %d2, %d3
436 ; ATOMIC-NEXT: seq %d2
437 ; ATOMIC-NEXT: sub.b #1, %d2
438 ; ATOMIC-NEXT: move.b %d0, %d2
439 ; ATOMIC-NEXT: beq .LBB8_4
440 ; ATOMIC-NEXT: .LBB8_1: ; %atomicrmw.start
441 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
442 ; ATOMIC-NEXT: move.b %d2, %d0
443 ; ATOMIC-NEXT: sub.b %d1, %d0
444 ; ATOMIC-NEXT: move.b %d2, %d3
445 ; ATOMIC-NEXT: bls .LBB8_3
446 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.start
447 ; ATOMIC-NEXT: ; in Loop: Header=BB8_1 Depth=1
448 ; ATOMIC-NEXT: move.b %d1, %d3
449 ; ATOMIC-NEXT: bra .LBB8_3
450 ; ATOMIC-NEXT: .LBB8_4: ; %atomicrmw.end
451 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
452 ; ATOMIC-NEXT: adda.l #8, %sp
454 %old = atomicrmw umin ptr %ptr, i8 %val release
458 define i16 @atomicrmw_umax_i16(i16 %val, ptr %ptr) {
459 ; NO-ATOMIC-LABEL: atomicrmw_umax_i16:
460 ; NO-ATOMIC: .cfi_startproc
461 ; NO-ATOMIC-NEXT: ; %bb.0:
462 ; NO-ATOMIC-NEXT: suba.l #12, %sp
463 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
464 ; NO-ATOMIC-NEXT: move.w (18,%sp), %d0
465 ; NO-ATOMIC-NEXT: and.l #65535, %d0
466 ; NO-ATOMIC-NEXT: move.l %d0, (4,%sp)
467 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
468 ; NO-ATOMIC-NEXT: jsr __sync_fetch_and_umax_2@PLT
469 ; NO-ATOMIC-NEXT: adda.l #12, %sp
470 ; NO-ATOMIC-NEXT: rts
472 ; ATOMIC-LABEL: atomicrmw_umax_i16:
473 ; ATOMIC: .cfi_startproc
474 ; ATOMIC-NEXT: ; %bb.0:
475 ; ATOMIC-NEXT: suba.l #8, %sp
476 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
477 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
478 ; ATOMIC-NEXT: move.w (14,%sp), %d1
479 ; ATOMIC-NEXT: move.l (16,%sp), %a0
480 ; ATOMIC-NEXT: move.w (%a0), %d2
481 ; ATOMIC-NEXT: bra .LBB9_1
482 ; ATOMIC-NEXT: .LBB9_3: ; %atomicrmw.start
483 ; ATOMIC-NEXT: ; in Loop: Header=BB9_1 Depth=1
484 ; ATOMIC-NEXT: move.w %d2, %d0
485 ; ATOMIC-NEXT: cas.w %d0, %d3, (%a0)
486 ; ATOMIC-NEXT: move.w %d0, %d3
487 ; ATOMIC-NEXT: sub.w %d2, %d3
488 ; ATOMIC-NEXT: seq %d2
489 ; ATOMIC-NEXT: sub.b #1, %d2
490 ; ATOMIC-NEXT: move.w %d0, %d2
491 ; ATOMIC-NEXT: beq .LBB9_4
492 ; ATOMIC-NEXT: .LBB9_1: ; %atomicrmw.start
493 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
494 ; ATOMIC-NEXT: move.w %d2, %d0
495 ; ATOMIC-NEXT: sub.w %d1, %d0
496 ; ATOMIC-NEXT: move.w %d2, %d3
497 ; ATOMIC-NEXT: bhi .LBB9_3
498 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.start
499 ; ATOMIC-NEXT: ; in Loop: Header=BB9_1 Depth=1
500 ; ATOMIC-NEXT: move.w %d1, %d3
501 ; ATOMIC-NEXT: bra .LBB9_3
502 ; ATOMIC-NEXT: .LBB9_4: ; %atomicrmw.end
503 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
504 ; ATOMIC-NEXT: adda.l #8, %sp
506 %old = atomicrmw umax ptr %ptr, i16 %val seq_cst
510 define i16 @atomicrmw_xchg_i16(i16 %val, ptr %ptr) {
511 ; NO-ATOMIC-LABEL: atomicrmw_xchg_i16:
512 ; NO-ATOMIC: .cfi_startproc
513 ; NO-ATOMIC-NEXT: ; %bb.0: ; %entry
514 ; NO-ATOMIC-NEXT: suba.l #12, %sp
515 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
516 ; NO-ATOMIC-NEXT: move.w (18,%sp), %d0
517 ; NO-ATOMIC-NEXT: and.l #65535, %d0
518 ; NO-ATOMIC-NEXT: move.l %d0, (4,%sp)
519 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
520 ; NO-ATOMIC-NEXT: jsr __sync_lock_test_and_set_2@PLT
521 ; NO-ATOMIC-NEXT: adda.l #12, %sp
522 ; NO-ATOMIC-NEXT: rts
524 ; ATOMIC-LABEL: atomicrmw_xchg_i16:
525 ; ATOMIC: .cfi_startproc
526 ; ATOMIC-NEXT: ; %bb.0: ; %entry
527 ; ATOMIC-NEXT: suba.l #8, %sp
528 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
529 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
530 ; ATOMIC-NEXT: move.w (14,%sp), %d1
531 ; ATOMIC-NEXT: move.l (16,%sp), %a0
532 ; ATOMIC-NEXT: move.w (%a0), %d2
533 ; ATOMIC-NEXT: move.w %d2, %d0
534 ; ATOMIC-NEXT: .LBB10_1: ; %atomicrmw.start
535 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
536 ; ATOMIC-NEXT: cas.w %d0, %d1, (%a0)
537 ; ATOMIC-NEXT: move.w %d0, %d3
538 ; ATOMIC-NEXT: sub.w %d2, %d3
539 ; ATOMIC-NEXT: seq %d2
540 ; ATOMIC-NEXT: sub.b #1, %d2
541 ; ATOMIC-NEXT: move.w %d0, %d2
542 ; ATOMIC-NEXT: bne .LBB10_1
543 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.end
544 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
545 ; ATOMIC-NEXT: adda.l #8, %sp
548 %old = atomicrmw xchg ptr %ptr, i16 %val monotonic
552 define i32 @atomicrmw_xchg_i32(i32 %val, ptr %ptr) {
553 ; NO-ATOMIC-LABEL: atomicrmw_xchg_i32:
554 ; NO-ATOMIC: .cfi_startproc
555 ; NO-ATOMIC-NEXT: ; %bb.0: ; %entry
556 ; NO-ATOMIC-NEXT: suba.l #12, %sp
557 ; NO-ATOMIC-NEXT: .cfi_def_cfa_offset -16
558 ; NO-ATOMIC-NEXT: move.l (16,%sp), (4,%sp)
559 ; NO-ATOMIC-NEXT: move.l (20,%sp), (%sp)
560 ; NO-ATOMIC-NEXT: jsr __sync_lock_test_and_set_4@PLT
561 ; NO-ATOMIC-NEXT: adda.l #12, %sp
562 ; NO-ATOMIC-NEXT: rts
564 ; ATOMIC-LABEL: atomicrmw_xchg_i32:
565 ; ATOMIC: .cfi_startproc
566 ; ATOMIC-NEXT: ; %bb.0: ; %entry
567 ; ATOMIC-NEXT: suba.l #8, %sp
568 ; ATOMIC-NEXT: .cfi_def_cfa_offset -12
569 ; ATOMIC-NEXT: movem.l %d2-%d3, (0,%sp) ; 12-byte Folded Spill
570 ; ATOMIC-NEXT: move.l (12,%sp), %d1
571 ; ATOMIC-NEXT: move.l (16,%sp), %a0
572 ; ATOMIC-NEXT: move.l (%a0), %d2
573 ; ATOMIC-NEXT: move.l %d2, %d0
574 ; ATOMIC-NEXT: .LBB11_1: ; %atomicrmw.start
575 ; ATOMIC-NEXT: ; =>This Inner Loop Header: Depth=1
576 ; ATOMIC-NEXT: cas.l %d0, %d1, (%a0)
577 ; ATOMIC-NEXT: move.l %d0, %d3
578 ; ATOMIC-NEXT: sub.l %d2, %d3
579 ; ATOMIC-NEXT: seq %d2
580 ; ATOMIC-NEXT: sub.b #1, %d2
581 ; ATOMIC-NEXT: move.l %d0, %d2
582 ; ATOMIC-NEXT: bne .LBB11_1
583 ; ATOMIC-NEXT: ; %bb.2: ; %atomicrmw.end
584 ; ATOMIC-NEXT: movem.l (0,%sp), %d2-%d3 ; 12-byte Folded Reload
585 ; ATOMIC-NEXT: adda.l #8, %sp
588 %old = atomicrmw xchg ptr %ptr, i32 %val monotonic