1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -O0 -mtriple=x86_64-- -mcpu=corei7 -verify-machineinstrs | FileCheck %s --check-prefix X64
3; RUN: llc < %s -O0 -mtriple=i386-- -mcpu=i486 -verify-machineinstrs | FileCheck %s --check-prefix I486
4
5@sc64 = external dso_local global i64
6@fsc64 = external dso_local global double
7
8define void @atomic_fetch_add64() nounwind {
9; X64-LABEL: atomic_fetch_add64:
10; X64:       # %bb.0: # %entry
11; X64-NEXT:    lock incq sc64(%rip)
12; X64-NEXT:    lock addq $3, sc64(%rip)
13; X64-NEXT:    movl $5, %eax
14; X64-NEXT:    lock xaddq %rax, sc64(%rip)
15; X64-NEXT:    lock addq %rax, sc64(%rip)
16; X64-NEXT:    retq
17;
18; I486-LABEL: atomic_fetch_add64:
19; I486:       # %bb.0: # %entry
20; I486-NEXT:    subl $16, %esp
21; I486-NEXT:    movl %esp, %eax
22; I486-NEXT:    movl $2, 12(%eax)
23; I486-NEXT:    movl $0, 8(%eax)
24; I486-NEXT:    movl $1, 4(%eax)
25; I486-NEXT:    movl $sc64, (%eax)
26; I486-NEXT:    calll __atomic_fetch_add_8@PLT
27; I486-NEXT:    movl %esp, %eax
28; I486-NEXT:    movl $2, 12(%eax)
29; I486-NEXT:    movl $0, 8(%eax)
30; I486-NEXT:    movl $3, 4(%eax)
31; I486-NEXT:    movl $sc64, (%eax)
32; I486-NEXT:    calll __atomic_fetch_add_8@PLT
33; I486-NEXT:    movl %esp, %eax
34; I486-NEXT:    movl $2, 12(%eax)
35; I486-NEXT:    movl $0, 8(%eax)
36; I486-NEXT:    movl $5, 4(%eax)
37; I486-NEXT:    movl $sc64, (%eax)
38; I486-NEXT:    calll __atomic_fetch_add_8@PLT
39; I486-NEXT:    movl %eax, %ecx
40; I486-NEXT:    movl %esp, %eax
41; I486-NEXT:    movl %edx, 8(%eax)
42; I486-NEXT:    movl %ecx, 4(%eax)
43; I486-NEXT:    movl $2, 12(%eax)
44; I486-NEXT:    movl $sc64, (%eax)
45; I486-NEXT:    calll __atomic_fetch_add_8@PLT
46; I486-NEXT:    addl $16, %esp
47; I486-NEXT:    retl
48entry:
49  %t1 = atomicrmw add  i64* @sc64, i64 1 acquire
50  %t2 = atomicrmw add  i64* @sc64, i64 3 acquire
51  %t3 = atomicrmw add  i64* @sc64, i64 5 acquire
52  %t4 = atomicrmw add  i64* @sc64, i64 %t3 acquire
53  ret void
54}
55
56define void @atomic_fetch_sub64() nounwind {
57; X64-LABEL: atomic_fetch_sub64:
58; X64:       # %bb.0:
59; X64-NEXT:    lock decq sc64(%rip)
60; X64-NEXT:    lock subq $3, sc64(%rip)
61; X64-NEXT:    movq $-5, %rax
62; X64-NEXT:    lock xaddq %rax, sc64(%rip)
63; X64-NEXT:    lock subq %rax, sc64(%rip)
64; X64-NEXT:    retq
65;
66; I486-LABEL: atomic_fetch_sub64:
67; I486:       # %bb.0:
68; I486-NEXT:    subl $16, %esp
69; I486-NEXT:    movl %esp, %eax
70; I486-NEXT:    movl $2, 12(%eax)
71; I486-NEXT:    movl $0, 8(%eax)
72; I486-NEXT:    movl $1, 4(%eax)
73; I486-NEXT:    movl $sc64, (%eax)
74; I486-NEXT:    calll __atomic_fetch_sub_8@PLT
75; I486-NEXT:    movl %esp, %eax
76; I486-NEXT:    movl $2, 12(%eax)
77; I486-NEXT:    movl $0, 8(%eax)
78; I486-NEXT:    movl $3, 4(%eax)
79; I486-NEXT:    movl $sc64, (%eax)
80; I486-NEXT:    calll __atomic_fetch_sub_8@PLT
81; I486-NEXT:    movl %esp, %eax
82; I486-NEXT:    movl $2, 12(%eax)
83; I486-NEXT:    movl $0, 8(%eax)
84; I486-NEXT:    movl $5, 4(%eax)
85; I486-NEXT:    movl $sc64, (%eax)
86; I486-NEXT:    calll __atomic_fetch_sub_8@PLT
87; I486-NEXT:    movl %eax, %ecx
88; I486-NEXT:    movl %esp, %eax
89; I486-NEXT:    movl %edx, 8(%eax)
90; I486-NEXT:    movl %ecx, 4(%eax)
91; I486-NEXT:    movl $2, 12(%eax)
92; I486-NEXT:    movl $sc64, (%eax)
93; I486-NEXT:    calll __atomic_fetch_sub_8@PLT
94; I486-NEXT:    addl $16, %esp
95; I486-NEXT:    retl
96  %t1 = atomicrmw sub  i64* @sc64, i64 1 acquire
97  %t2 = atomicrmw sub  i64* @sc64, i64 3 acquire
98  %t3 = atomicrmw sub  i64* @sc64, i64 5 acquire
99  %t4 = atomicrmw sub  i64* @sc64, i64 %t3 acquire
100  ret void
101}
102
103define void @atomic_fetch_and64() nounwind {
104; X64-LABEL: atomic_fetch_and64:
105; X64:       # %bb.0:
106; X64-NEXT:    lock andq $3, sc64(%rip)
107; X64-NEXT:    movq sc64, %rax
108; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
109; X64-NEXT:  .LBB2_1: # %atomicrmw.start
110; X64-NEXT:    # =>This Inner Loop Header: Depth=1
111; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
112; X64-NEXT:    movl %eax, %ecx
113; X64-NEXT:    andl $5, %ecx
114; X64-NEXT:    # kill: def $rcx killed $ecx
115; X64-NEXT:    lock cmpxchgq %rcx, sc64(%rip)
116; X64-NEXT:    sete %cl
117; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
118; X64-NEXT:    testb $1, %cl
119; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
120; X64-NEXT:    jne .LBB2_2
121; X64-NEXT:    jmp .LBB2_1
122; X64-NEXT:  .LBB2_2: # %atomicrmw.end
123; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
124; X64-NEXT:    lock andq %rax, sc64(%rip)
125; X64-NEXT:    retq
126;
127; I486-LABEL: atomic_fetch_and64:
128; I486:       # %bb.0:
129; I486-NEXT:    subl $16, %esp
130; I486-NEXT:    movl %esp, %eax
131; I486-NEXT:    movl $2, 12(%eax)
132; I486-NEXT:    movl $0, 8(%eax)
133; I486-NEXT:    movl $3, 4(%eax)
134; I486-NEXT:    movl $sc64, (%eax)
135; I486-NEXT:    calll __atomic_fetch_and_8@PLT
136; I486-NEXT:    movl %esp, %eax
137; I486-NEXT:    movl $2, 12(%eax)
138; I486-NEXT:    movl $0, 8(%eax)
139; I486-NEXT:    movl $5, 4(%eax)
140; I486-NEXT:    movl $sc64, (%eax)
141; I486-NEXT:    calll __atomic_fetch_and_8@PLT
142; I486-NEXT:    movl %eax, %ecx
143; I486-NEXT:    movl %esp, %eax
144; I486-NEXT:    movl %edx, 8(%eax)
145; I486-NEXT:    movl %ecx, 4(%eax)
146; I486-NEXT:    movl $2, 12(%eax)
147; I486-NEXT:    movl $sc64, (%eax)
148; I486-NEXT:    calll __atomic_fetch_and_8@PLT
149; I486-NEXT:    addl $16, %esp
150; I486-NEXT:    retl
151  %t1 = atomicrmw and  i64* @sc64, i64 3 acquire
152  %t2 = atomicrmw and  i64* @sc64, i64 5 acquire
153  %t3 = atomicrmw and  i64* @sc64, i64 %t2 acquire
154  ret void
155}
156
157define void @atomic_fetch_or64() nounwind {
158; X64-LABEL: atomic_fetch_or64:
159; X64:       # %bb.0:
160; X64-NEXT:    lock orq $3, sc64(%rip)
161; X64-NEXT:    movq sc64, %rax
162; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
163; X64-NEXT:  .LBB3_1: # %atomicrmw.start
164; X64-NEXT:    # =>This Inner Loop Header: Depth=1
165; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
166; X64-NEXT:    movq %rax, %rcx
167; X64-NEXT:    orq $5, %rcx
168; X64-NEXT:    lock cmpxchgq %rcx, sc64(%rip)
169; X64-NEXT:    sete %cl
170; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
171; X64-NEXT:    testb $1, %cl
172; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
173; X64-NEXT:    jne .LBB3_2
174; X64-NEXT:    jmp .LBB3_1
175; X64-NEXT:  .LBB3_2: # %atomicrmw.end
176; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
177; X64-NEXT:    lock orq %rax, sc64(%rip)
178; X64-NEXT:    retq
179;
180; I486-LABEL: atomic_fetch_or64:
181; I486:       # %bb.0:
182; I486-NEXT:    subl $16, %esp
183; I486-NEXT:    movl %esp, %eax
184; I486-NEXT:    movl $2, 12(%eax)
185; I486-NEXT:    movl $0, 8(%eax)
186; I486-NEXT:    movl $3, 4(%eax)
187; I486-NEXT:    movl $sc64, (%eax)
188; I486-NEXT:    calll __atomic_fetch_or_8@PLT
189; I486-NEXT:    movl %esp, %eax
190; I486-NEXT:    movl $2, 12(%eax)
191; I486-NEXT:    movl $0, 8(%eax)
192; I486-NEXT:    movl $5, 4(%eax)
193; I486-NEXT:    movl $sc64, (%eax)
194; I486-NEXT:    calll __atomic_fetch_or_8@PLT
195; I486-NEXT:    movl %eax, %ecx
196; I486-NEXT:    movl %esp, %eax
197; I486-NEXT:    movl %edx, 8(%eax)
198; I486-NEXT:    movl %ecx, 4(%eax)
199; I486-NEXT:    movl $2, 12(%eax)
200; I486-NEXT:    movl $sc64, (%eax)
201; I486-NEXT:    calll __atomic_fetch_or_8@PLT
202; I486-NEXT:    addl $16, %esp
203; I486-NEXT:    retl
204  %t1 = atomicrmw or   i64* @sc64, i64 3 acquire
205  %t2 = atomicrmw or   i64* @sc64, i64 5 acquire
206  %t3 = atomicrmw or   i64* @sc64, i64 %t2 acquire
207  ret void
208}
209
210define void @atomic_fetch_xor64() nounwind {
211; X64-LABEL: atomic_fetch_xor64:
212; X64:       # %bb.0:
213; X64-NEXT:    lock xorq $3, sc64(%rip)
214; X64-NEXT:    movq sc64, %rax
215; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
216; X64-NEXT:  .LBB4_1: # %atomicrmw.start
217; X64-NEXT:    # =>This Inner Loop Header: Depth=1
218; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
219; X64-NEXT:    movq %rax, %rcx
220; X64-NEXT:    xorq $5, %rcx
221; X64-NEXT:    lock cmpxchgq %rcx, sc64(%rip)
222; X64-NEXT:    sete %cl
223; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
224; X64-NEXT:    testb $1, %cl
225; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
226; X64-NEXT:    jne .LBB4_2
227; X64-NEXT:    jmp .LBB4_1
228; X64-NEXT:  .LBB4_2: # %atomicrmw.end
229; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
230; X64-NEXT:    lock xorq %rax, sc64(%rip)
231; X64-NEXT:    retq
232;
233; I486-LABEL: atomic_fetch_xor64:
234; I486:       # %bb.0:
235; I486-NEXT:    subl $16, %esp
236; I486-NEXT:    movl %esp, %eax
237; I486-NEXT:    movl $2, 12(%eax)
238; I486-NEXT:    movl $0, 8(%eax)
239; I486-NEXT:    movl $3, 4(%eax)
240; I486-NEXT:    movl $sc64, (%eax)
241; I486-NEXT:    calll __atomic_fetch_xor_8@PLT
242; I486-NEXT:    movl %esp, %eax
243; I486-NEXT:    movl $2, 12(%eax)
244; I486-NEXT:    movl $0, 8(%eax)
245; I486-NEXT:    movl $5, 4(%eax)
246; I486-NEXT:    movl $sc64, (%eax)
247; I486-NEXT:    calll __atomic_fetch_xor_8@PLT
248; I486-NEXT:    movl %eax, %ecx
249; I486-NEXT:    movl %esp, %eax
250; I486-NEXT:    movl %edx, 8(%eax)
251; I486-NEXT:    movl %ecx, 4(%eax)
252; I486-NEXT:    movl $2, 12(%eax)
253; I486-NEXT:    movl $sc64, (%eax)
254; I486-NEXT:    calll __atomic_fetch_xor_8@PLT
255; I486-NEXT:    addl $16, %esp
256; I486-NEXT:    retl
257  %t1 = atomicrmw xor  i64* @sc64, i64 3 acquire
258  %t2 = atomicrmw xor  i64* @sc64, i64 5 acquire
259  %t3 = atomicrmw xor  i64* @sc64, i64 %t2 acquire
260  ret void
261}
262
263define void @atomic_fetch_nand64(i64 %x) nounwind {
264; X64-LABEL: atomic_fetch_nand64:
265; X64:       # %bb.0:
266; X64-NEXT:    movq %rdi, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
267; X64-NEXT:    movq sc64, %rax
268; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
269; X64-NEXT:  .LBB5_1: # %atomicrmw.start
270; X64-NEXT:    # =>This Inner Loop Header: Depth=1
271; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
272; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rdx # 8-byte Reload
273; X64-NEXT:    movq %rax, %rcx
274; X64-NEXT:    andq %rdx, %rcx
275; X64-NEXT:    movq %rcx, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
276; X64-NEXT:    notq %rcx
277; X64-NEXT:    lock cmpxchgq %rcx, sc64(%rip)
278; X64-NEXT:    sete %cl
279; X64-NEXT:    testb $1, %cl
280; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
281; X64-NEXT:    jne .LBB5_2
282; X64-NEXT:    jmp .LBB5_1
283; X64-NEXT:  .LBB5_2: # %atomicrmw.end
284; X64-NEXT:    retq
285;
286; I486-LABEL: atomic_fetch_nand64:
287; I486:       # %bb.0:
288; I486-NEXT:    subl $16, %esp
289; I486-NEXT:    movl {{[0-9]+}}(%esp), %edx
290; I486-NEXT:    movl {{[0-9]+}}(%esp), %ecx
291; I486-NEXT:    movl %esp, %eax
292; I486-NEXT:    movl %edx, 8(%eax)
293; I486-NEXT:    movl %ecx, 4(%eax)
294; I486-NEXT:    movl $2, 12(%eax)
295; I486-NEXT:    movl $sc64, (%eax)
296; I486-NEXT:    calll __atomic_fetch_nand_8@PLT
297; I486-NEXT:    addl $16, %esp
298; I486-NEXT:    retl
299  %t1 = atomicrmw nand i64* @sc64, i64 %x acquire
300  ret void
301}
302
303define void @atomic_fetch_max64(i64 %x) nounwind {
304; X64-LABEL: atomic_fetch_max64:
305; X64:       # %bb.0:
306; X64-NEXT:    movq %rdi, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
307; X64-NEXT:    movq sc64, %rax
308; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
309; X64-NEXT:  .LBB6_1: # %atomicrmw.start
310; X64-NEXT:    # =>This Inner Loop Header: Depth=1
311; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
312; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rcx # 8-byte Reload
313; X64-NEXT:    movq %rax, %rdx
314; X64-NEXT:    subq %rcx, %rdx
315; X64-NEXT:    movq %rdx, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
316; X64-NEXT:    cmovgq %rax, %rcx
317; X64-NEXT:    lock cmpxchgq %rcx, sc64(%rip)
318; X64-NEXT:    sete %cl
319; X64-NEXT:    testb $1, %cl
320; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
321; X64-NEXT:    jne .LBB6_2
322; X64-NEXT:    jmp .LBB6_1
323; X64-NEXT:  .LBB6_2: # %atomicrmw.end
324; X64-NEXT:    retq
325;
326; I486-LABEL: atomic_fetch_max64:
327; I486:       # %bb.0:
328; I486-NEXT:    pushl %ebp
329; I486-NEXT:    movl %esp, %ebp
330; I486-NEXT:    pushl %esi
331; I486-NEXT:    andl $-8, %esp
332; I486-NEXT:    subl $72, %esp
333; I486-NEXT:    movl 12(%ebp), %eax
334; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
335; I486-NEXT:    movl 8(%ebp), %eax
336; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
337; I486-NEXT:    movl sc64+4, %eax
338; I486-NEXT:    movl sc64, %ecx
339; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
340; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
341; I486-NEXT:    jmp .LBB6_1
342; I486-NEXT:  .LBB6_1: # %atomicrmw.start
343; I486-NEXT:    # =>This Inner Loop Header: Depth=1
344; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
345; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
346; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
347; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
348; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
349; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
350; I486-NEXT:    subl %ecx, %esi
351; I486-NEXT:    sbbl %eax, %edx
352; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
353; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
354; I486-NEXT:    jl .LBB6_4
355; I486-NEXT:  # %bb.3: # %atomicrmw.start
356; I486-NEXT:    # in Loop: Header=BB6_1 Depth=1
357; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
358; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
359; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
360; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
361; I486-NEXT:  .LBB6_4: # %atomicrmw.start
362; I486-NEXT:    # in Loop: Header=BB6_1 Depth=1
363; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
364; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
365; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
366; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
367; I486-NEXT:    movl %esi, {{[0-9]+}}(%esp)
368; I486-NEXT:    movl %eax, {{[0-9]+}}(%esp)
369; I486-NEXT:    movl %esp, %eax
370; I486-NEXT:    movl %edx, 12(%eax)
371; I486-NEXT:    movl %ecx, 8(%eax)
372; I486-NEXT:    leal {{[0-9]+}}(%esp), %ecx
373; I486-NEXT:    movl %ecx, 4(%eax)
374; I486-NEXT:    movl $2, 20(%eax)
375; I486-NEXT:    movl $2, 16(%eax)
376; I486-NEXT:    movl $sc64, (%eax)
377; I486-NEXT:    calll __atomic_compare_exchange_8@PLT
378; I486-NEXT:    movb %al, %dl
379; I486-NEXT:    movl {{[0-9]+}}(%esp), %ecx
380; I486-NEXT:    movl {{[0-9]+}}(%esp), %eax
381; I486-NEXT:    testb %dl, %dl
382; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
383; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
384; I486-NEXT:    je .LBB6_1
385; I486-NEXT:    jmp .LBB6_2
386; I486-NEXT:  .LBB6_2: # %atomicrmw.end
387; I486-NEXT:    leal -4(%ebp), %esp
388; I486-NEXT:    popl %esi
389; I486-NEXT:    popl %ebp
390; I486-NEXT:    retl
391  %t1 = atomicrmw max  i64* @sc64, i64 %x acquire
392
393  ret void
394}
395
396define void @atomic_fetch_min64(i64 %x) nounwind {
397; X64-LABEL: atomic_fetch_min64:
398; X64:       # %bb.0:
399; X64-NEXT:    movq %rdi, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
400; X64-NEXT:    movq sc64, %rax
401; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
402; X64-NEXT:  .LBB7_1: # %atomicrmw.start
403; X64-NEXT:    # =>This Inner Loop Header: Depth=1
404; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
405; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rcx # 8-byte Reload
406; X64-NEXT:    movq %rax, %rdx
407; X64-NEXT:    subq %rcx, %rdx
408; X64-NEXT:    movq %rdx, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
409; X64-NEXT:    cmovleq %rax, %rcx
410; X64-NEXT:    lock cmpxchgq %rcx, sc64(%rip)
411; X64-NEXT:    sete %cl
412; X64-NEXT:    testb $1, %cl
413; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
414; X64-NEXT:    jne .LBB7_2
415; X64-NEXT:    jmp .LBB7_1
416; X64-NEXT:  .LBB7_2: # %atomicrmw.end
417; X64-NEXT:    retq
418;
419; I486-LABEL: atomic_fetch_min64:
420; I486:       # %bb.0:
421; I486-NEXT:    pushl %ebp
422; I486-NEXT:    movl %esp, %ebp
423; I486-NEXT:    pushl %esi
424; I486-NEXT:    andl $-8, %esp
425; I486-NEXT:    subl $72, %esp
426; I486-NEXT:    movl 12(%ebp), %eax
427; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
428; I486-NEXT:    movl 8(%ebp), %eax
429; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
430; I486-NEXT:    movl sc64+4, %eax
431; I486-NEXT:    movl sc64, %ecx
432; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
433; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
434; I486-NEXT:    jmp .LBB7_1
435; I486-NEXT:  .LBB7_1: # %atomicrmw.start
436; I486-NEXT:    # =>This Inner Loop Header: Depth=1
437; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
438; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
439; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
440; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
441; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
442; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
443; I486-NEXT:    subl %ecx, %esi
444; I486-NEXT:    sbbl %eax, %edx
445; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
446; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
447; I486-NEXT:    jge .LBB7_4
448; I486-NEXT:  # %bb.3: # %atomicrmw.start
449; I486-NEXT:    # in Loop: Header=BB7_1 Depth=1
450; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
451; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
452; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
453; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
454; I486-NEXT:  .LBB7_4: # %atomicrmw.start
455; I486-NEXT:    # in Loop: Header=BB7_1 Depth=1
456; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
457; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
458; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
459; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
460; I486-NEXT:    movl %esi, {{[0-9]+}}(%esp)
461; I486-NEXT:    movl %eax, {{[0-9]+}}(%esp)
462; I486-NEXT:    movl %esp, %eax
463; I486-NEXT:    movl %edx, 12(%eax)
464; I486-NEXT:    movl %ecx, 8(%eax)
465; I486-NEXT:    leal {{[0-9]+}}(%esp), %ecx
466; I486-NEXT:    movl %ecx, 4(%eax)
467; I486-NEXT:    movl $2, 20(%eax)
468; I486-NEXT:    movl $2, 16(%eax)
469; I486-NEXT:    movl $sc64, (%eax)
470; I486-NEXT:    calll __atomic_compare_exchange_8@PLT
471; I486-NEXT:    movb %al, %dl
472; I486-NEXT:    movl {{[0-9]+}}(%esp), %ecx
473; I486-NEXT:    movl {{[0-9]+}}(%esp), %eax
474; I486-NEXT:    testb %dl, %dl
475; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
476; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
477; I486-NEXT:    je .LBB7_1
478; I486-NEXT:    jmp .LBB7_2
479; I486-NEXT:  .LBB7_2: # %atomicrmw.end
480; I486-NEXT:    leal -4(%ebp), %esp
481; I486-NEXT:    popl %esi
482; I486-NEXT:    popl %ebp
483; I486-NEXT:    retl
484  %t1 = atomicrmw min  i64* @sc64, i64 %x acquire
485
486  ret void
487}
488
489define void @atomic_fetch_umax64(i64 %x) nounwind {
490; X64-LABEL: atomic_fetch_umax64:
491; X64:       # %bb.0:
492; X64-NEXT:    movq %rdi, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
493; X64-NEXT:    movq sc64, %rax
494; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
495; X64-NEXT:  .LBB8_1: # %atomicrmw.start
496; X64-NEXT:    # =>This Inner Loop Header: Depth=1
497; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
498; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rcx # 8-byte Reload
499; X64-NEXT:    movq %rax, %rdx
500; X64-NEXT:    subq %rcx, %rdx
501; X64-NEXT:    movq %rdx, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
502; X64-NEXT:    cmovaq %rax, %rcx
503; X64-NEXT:    lock cmpxchgq %rcx, sc64(%rip)
504; X64-NEXT:    sete %cl
505; X64-NEXT:    testb $1, %cl
506; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
507; X64-NEXT:    jne .LBB8_2
508; X64-NEXT:    jmp .LBB8_1
509; X64-NEXT:  .LBB8_2: # %atomicrmw.end
510; X64-NEXT:    retq
511;
512; I486-LABEL: atomic_fetch_umax64:
513; I486:       # %bb.0:
514; I486-NEXT:    pushl %ebp
515; I486-NEXT:    movl %esp, %ebp
516; I486-NEXT:    pushl %esi
517; I486-NEXT:    andl $-8, %esp
518; I486-NEXT:    subl $72, %esp
519; I486-NEXT:    movl 12(%ebp), %eax
520; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
521; I486-NEXT:    movl 8(%ebp), %eax
522; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
523; I486-NEXT:    movl sc64+4, %eax
524; I486-NEXT:    movl sc64, %ecx
525; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
526; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
527; I486-NEXT:    jmp .LBB8_1
528; I486-NEXT:  .LBB8_1: # %atomicrmw.start
529; I486-NEXT:    # =>This Inner Loop Header: Depth=1
530; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
531; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
532; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
533; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
534; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
535; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
536; I486-NEXT:    subl %ecx, %esi
537; I486-NEXT:    sbbl %eax, %edx
538; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
539; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
540; I486-NEXT:    jb .LBB8_4
541; I486-NEXT:  # %bb.3: # %atomicrmw.start
542; I486-NEXT:    # in Loop: Header=BB8_1 Depth=1
543; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
544; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
545; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
546; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
547; I486-NEXT:  .LBB8_4: # %atomicrmw.start
548; I486-NEXT:    # in Loop: Header=BB8_1 Depth=1
549; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
550; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
551; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
552; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
553; I486-NEXT:    movl %esi, {{[0-9]+}}(%esp)
554; I486-NEXT:    movl %eax, {{[0-9]+}}(%esp)
555; I486-NEXT:    movl %esp, %eax
556; I486-NEXT:    movl %edx, 12(%eax)
557; I486-NEXT:    movl %ecx, 8(%eax)
558; I486-NEXT:    leal {{[0-9]+}}(%esp), %ecx
559; I486-NEXT:    movl %ecx, 4(%eax)
560; I486-NEXT:    movl $2, 20(%eax)
561; I486-NEXT:    movl $2, 16(%eax)
562; I486-NEXT:    movl $sc64, (%eax)
563; I486-NEXT:    calll __atomic_compare_exchange_8@PLT
564; I486-NEXT:    movb %al, %dl
565; I486-NEXT:    movl {{[0-9]+}}(%esp), %ecx
566; I486-NEXT:    movl {{[0-9]+}}(%esp), %eax
567; I486-NEXT:    testb %dl, %dl
568; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
569; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
570; I486-NEXT:    je .LBB8_1
571; I486-NEXT:    jmp .LBB8_2
572; I486-NEXT:  .LBB8_2: # %atomicrmw.end
573; I486-NEXT:    leal -4(%ebp), %esp
574; I486-NEXT:    popl %esi
575; I486-NEXT:    popl %ebp
576; I486-NEXT:    retl
577  %t1 = atomicrmw umax i64* @sc64, i64 %x acquire
578
579  ret void
580}
581
582define void @atomic_fetch_umin64(i64 %x) nounwind {
583; X64-LABEL: atomic_fetch_umin64:
584; X64:       # %bb.0:
585; X64-NEXT:    movq %rdi, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
586; X64-NEXT:    movq sc64, %rax
587; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
588; X64-NEXT:  .LBB9_1: # %atomicrmw.start
589; X64-NEXT:    # =>This Inner Loop Header: Depth=1
590; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
591; X64-NEXT:    movq {{[-0-9]+}}(%r{{[sb]}}p), %rcx # 8-byte Reload
592; X64-NEXT:    movq %rax, %rdx
593; X64-NEXT:    subq %rcx, %rdx
594; X64-NEXT:    movq %rdx, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
595; X64-NEXT:    cmovbeq %rax, %rcx
596; X64-NEXT:    lock cmpxchgq %rcx, sc64(%rip)
597; X64-NEXT:    sete %cl
598; X64-NEXT:    testb $1, %cl
599; X64-NEXT:    movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
600; X64-NEXT:    jne .LBB9_2
601; X64-NEXT:    jmp .LBB9_1
602; X64-NEXT:  .LBB9_2: # %atomicrmw.end
603; X64-NEXT:    retq
604;
605; I486-LABEL: atomic_fetch_umin64:
606; I486:       # %bb.0:
607; I486-NEXT:    pushl %ebp
608; I486-NEXT:    movl %esp, %ebp
609; I486-NEXT:    pushl %esi
610; I486-NEXT:    andl $-8, %esp
611; I486-NEXT:    subl $72, %esp
612; I486-NEXT:    movl 12(%ebp), %eax
613; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
614; I486-NEXT:    movl 8(%ebp), %eax
615; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
616; I486-NEXT:    movl sc64+4, %eax
617; I486-NEXT:    movl sc64, %ecx
618; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
619; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
620; I486-NEXT:    jmp .LBB9_1
621; I486-NEXT:  .LBB9_1: # %atomicrmw.start
622; I486-NEXT:    # =>This Inner Loop Header: Depth=1
623; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
624; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
625; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
626; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
627; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
628; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
629; I486-NEXT:    subl %ecx, %esi
630; I486-NEXT:    sbbl %eax, %edx
631; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
632; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
633; I486-NEXT:    jae .LBB9_4
634; I486-NEXT:  # %bb.3: # %atomicrmw.start
635; I486-NEXT:    # in Loop: Header=BB9_1 Depth=1
636; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
637; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
638; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
639; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
640; I486-NEXT:  .LBB9_4: # %atomicrmw.start
641; I486-NEXT:    # in Loop: Header=BB9_1 Depth=1
642; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
643; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
644; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
645; I486-NEXT:    movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
646; I486-NEXT:    movl %esi, {{[0-9]+}}(%esp)
647; I486-NEXT:    movl %eax, {{[0-9]+}}(%esp)
648; I486-NEXT:    movl %esp, %eax
649; I486-NEXT:    movl %edx, 12(%eax)
650; I486-NEXT:    movl %ecx, 8(%eax)
651; I486-NEXT:    leal {{[0-9]+}}(%esp), %ecx
652; I486-NEXT:    movl %ecx, 4(%eax)
653; I486-NEXT:    movl $2, 20(%eax)
654; I486-NEXT:    movl $2, 16(%eax)
655; I486-NEXT:    movl $sc64, (%eax)
656; I486-NEXT:    calll __atomic_compare_exchange_8@PLT
657; I486-NEXT:    movb %al, %dl
658; I486-NEXT:    movl {{[0-9]+}}(%esp), %ecx
659; I486-NEXT:    movl {{[0-9]+}}(%esp), %eax
660; I486-NEXT:    testb %dl, %dl
661; I486-NEXT:    movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
662; I486-NEXT:    movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
663; I486-NEXT:    je .LBB9_1
664; I486-NEXT:    jmp .LBB9_2
665; I486-NEXT:  .LBB9_2: # %atomicrmw.end
666; I486-NEXT:    leal -4(%ebp), %esp
667; I486-NEXT:    popl %esi
668; I486-NEXT:    popl %ebp
669; I486-NEXT:    retl
670  %t1 = atomicrmw umin i64* @sc64, i64 %x acquire
671
672  ret void
673}
674
675define void @atomic_fetch_cmpxchg64() nounwind {
676; X64-LABEL: atomic_fetch_cmpxchg64:
677; X64:       # %bb.0:
678; X64-NEXT:    xorl %eax, %eax
679; X64-NEXT:    # kill: def $rax killed $eax
680; X64-NEXT:    movl $1, %ecx
681; X64-NEXT:    lock cmpxchgq %rcx, sc64(%rip)
682; X64-NEXT:    retq
683;
684; I486-LABEL: atomic_fetch_cmpxchg64:
685; I486:       # %bb.0:
686; I486-NEXT:    pushl %ebp
687; I486-NEXT:    movl %esp, %ebp
688; I486-NEXT:    andl $-8, %esp
689; I486-NEXT:    subl $32, %esp
690; I486-NEXT:    leal {{[0-9]+}}(%esp), %ecx
691; I486-NEXT:    movl $0, {{[0-9]+}}(%esp)
692; I486-NEXT:    movl $0, {{[0-9]+}}(%esp)
693; I486-NEXT:    movl %esp, %eax
694; I486-NEXT:    movl %ecx, 4(%eax)
695; I486-NEXT:    movl $2, 20(%eax)
696; I486-NEXT:    movl $2, 16(%eax)
697; I486-NEXT:    movl $0, 12(%eax)
698; I486-NEXT:    movl $1, 8(%eax)
699; I486-NEXT:    movl $sc64, (%eax)
700; I486-NEXT:    calll __atomic_compare_exchange_8@PLT
701; I486-NEXT:    movl %ebp, %esp
702; I486-NEXT:    popl %ebp
703; I486-NEXT:    retl
704  %t1 = cmpxchg i64* @sc64, i64 0, i64 1 acquire acquire
705  ret void
706}
707
708define void @atomic_fetch_store64(i64 %x) nounwind {
709; X64-LABEL: atomic_fetch_store64:
710; X64:       # %bb.0:
711; X64-NEXT:    movq %rdi, sc64(%rip)
712; X64-NEXT:    retq
713;
714; I486-LABEL: atomic_fetch_store64:
715; I486:       # %bb.0:
716; I486-NEXT:    subl $16, %esp
717; I486-NEXT:    movl {{[0-9]+}}(%esp), %edx
718; I486-NEXT:    movl {{[0-9]+}}(%esp), %ecx
719; I486-NEXT:    movl %esp, %eax
720; I486-NEXT:    movl %edx, 8(%eax)
721; I486-NEXT:    movl %ecx, 4(%eax)
722; I486-NEXT:    movl $3, 12(%eax)
723; I486-NEXT:    movl $sc64, (%eax)
724; I486-NEXT:    calll __atomic_store_8@PLT
725; I486-NEXT:    addl $16, %esp
726; I486-NEXT:    retl
727  store atomic i64 %x, i64* @sc64 release, align 8
728  ret void
729}
730
731define void @atomic_fetch_swap64(i64 %x) nounwind {
732; X64-LABEL: atomic_fetch_swap64:
733; X64:       # %bb.0:
734; X64-NEXT:    xchgq %rdi, sc64(%rip)
735; X64-NEXT:    retq
736;
737; I486-LABEL: atomic_fetch_swap64:
738; I486:       # %bb.0:
739; I486-NEXT:    subl $16, %esp
740; I486-NEXT:    movl {{[0-9]+}}(%esp), %edx
741; I486-NEXT:    movl {{[0-9]+}}(%esp), %ecx
742; I486-NEXT:    movl %esp, %eax
743; I486-NEXT:    movl %edx, 8(%eax)
744; I486-NEXT:    movl %ecx, 4(%eax)
745; I486-NEXT:    movl $2, 12(%eax)
746; I486-NEXT:    movl $sc64, (%eax)
747; I486-NEXT:    calll __atomic_exchange_8@PLT
748; I486-NEXT:    addl $16, %esp
749; I486-NEXT:    retl
750  %t1 = atomicrmw xchg i64* @sc64, i64 %x acquire
751  ret void
752}
753
754define void @atomic_fetch_swapf64(double %x) nounwind {
755; X64-LABEL: atomic_fetch_swapf64:
756; X64:       # %bb.0:
757; X64-NEXT:    movq %xmm0, %rax
758; X64-NEXT:    xchgq %rax, fsc64(%rip)
759; X64-NEXT:    retq
760;
761; I486-LABEL: atomic_fetch_swapf64:
762; I486:       # %bb.0:
763; I486-NEXT:    pushl %ebp
764; I486-NEXT:    movl %esp, %ebp
765; I486-NEXT:    andl $-8, %esp
766; I486-NEXT:    subl $24, %esp
767; I486-NEXT:    fldl 8(%ebp)
768; I486-NEXT:    fstpl {{[0-9]+}}(%esp)
769; I486-NEXT:    movl {{[0-9]+}}(%esp), %ecx
770; I486-NEXT:    movl {{[0-9]+}}(%esp), %edx
771; I486-NEXT:    movl %esp, %eax
772; I486-NEXT:    movl %edx, 8(%eax)
773; I486-NEXT:    movl %ecx, 4(%eax)
774; I486-NEXT:    movl $2, 12(%eax)
775; I486-NEXT:    movl $fsc64, (%eax)
776; I486-NEXT:    calll __atomic_exchange_8@PLT
777; I486-NEXT:    movl %ebp, %esp
778; I486-NEXT:    popl %ebp
779; I486-NEXT:    retl
780  %t1 = atomicrmw xchg double* @fsc64, double %x acquire
781  ret void
782}
783