• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -O0 -mtriple=x86_64-unknown-unknown -mcpu=corei7 -verify-machineinstrs -show-mc-encoding | FileCheck %s --check-prefix X64
2; RUN: llc < %s -O0 -mtriple=i386-unknown-unknown -mcpu=corei7 -verify-machineinstrs | FileCheck %s --check-prefix X32
3
4@sc16 = external dso_local global i16
5@fsc16 = external dso_local global half
6
7define void @atomic_fetch_add16() nounwind {
8; X64-LABEL:   atomic_fetch_add16
9; X32-LABEL:   atomic_fetch_add16
10entry:
11; 32-bit
12  %t1 = atomicrmw add  i16* @sc16, i16 1 acquire
13; X64:       lock
14; X64:       incw
15; X32:       lock
16; X32:       incw
17  %t2 = atomicrmw add  i16* @sc16, i16 3 acquire
18; X64:       lock
19; X64:       addw $3, {{.*}} # encoding: [0x66,0xf0
20; X32:       lock
21; X32:       addw $3
22  %t3 = atomicrmw add  i16* @sc16, i16 5 acquire
23; X64:       lock
24; X64:       xaddw {{.*}} # encoding: [0x66,0xf0
25; X32:       lock
26; X32:       xaddw
27  %t4 = atomicrmw add  i16* @sc16, i16 %t3 acquire
28; X64:       lock
29; X64:       addw {{.*}} # encoding: [0x66,0xf0
30; X32:       lock
31; X32:       addw
32  ret void
33; X64:       ret
34; X32:       ret
35}
36
37define void @atomic_fetch_sub16() nounwind {
38; X64-LABEL:   atomic_fetch_sub16
39; X32-LABEL:   atomic_fetch_sub16
40  %t1 = atomicrmw sub  i16* @sc16, i16 1 acquire
41; X64:       lock
42; X64:       decw
43; X32:       lock
44; X32:       decw
45  %t2 = atomicrmw sub  i16* @sc16, i16 3 acquire
46; X64:       lock
47; X64:       subw $3, {{.*}} # encoding: [0x66,0xf0
48; X32:       lock
49; X32:       subw $3
50  %t3 = atomicrmw sub  i16* @sc16, i16 5 acquire
51; X64:       lock
52; X64:       xaddw {{.*}} # encoding: [0x66,0xf0
53; X32:       lock
54; X32:       xaddw
55  %t4 = atomicrmw sub  i16* @sc16, i16 %t3 acquire
56; X64:       lock
57; X64:       subw {{.*}} # encoding: [0x66,0xf0
58; X32:       lock
59; X32:       subw
60  ret void
61; X64:       ret
62; X32:       ret
63}
64
65define void @atomic_fetch_and16() nounwind {
66; X64-LABEL:   atomic_fetch_and16
67; X32-LABEL:   atomic_fetch_and16
68  %t1 = atomicrmw and  i16* @sc16, i16 3 acquire
69; X64:       lock
70; X64:       andw $3, {{.*}} # encoding: [0x66,0xf0
71; X32:       lock
72; X32:       andw $3
73  %t2 = atomicrmw and  i16* @sc16, i16 5 acquire
74; X64:       andl
75; X64:       lock
76; X64:       cmpxchgw
77; X32:       andl
78; X32:       lock
79; X32:       cmpxchgw
80  %t3 = atomicrmw and  i16* @sc16, i16 %t2 acquire
81; X64:       lock
82; X64:       andw {{.*}} # encoding: [0x66,0xf0
83; X32:       lock
84; X32:       andw
85  ret void
86; X64:       ret
87; X32:       ret
88}
89
90define void @atomic_fetch_or16() nounwind {
91; X64-LABEL:   atomic_fetch_or16
92; X32-LABEL:   atomic_fetch_or16
93  %t1 = atomicrmw or   i16* @sc16, i16 3 acquire
94; X64:       lock
95; X64:       orw $3, {{.*}} # encoding: [0x66,0xf0
96; X32:       lock
97; X32:       orw $3
98  %t2 = atomicrmw or   i16* @sc16, i16 5 acquire
99; X64:       orl
100; X64:       lock
101; X64:       cmpxchgw
102; X32:       orl
103; X32:       lock
104; X32:       cmpxchgw
105  %t3 = atomicrmw or   i16* @sc16, i16 %t2 acquire
106; X64:       lock
107; X64:       orw {{.*}} # encoding: [0x66,0xf0
108; X32:       lock
109; X32:       orw
110  ret void
111; X64:       ret
112; X32:       ret
113}
114
115define void @atomic_fetch_xor16() nounwind {
116; X64-LABEL:   atomic_fetch_xor16
117; X32-LABEL:   atomic_fetch_xor16
118  %t1 = atomicrmw xor  i16* @sc16, i16 3 acquire
119; X64:       lock
120; X64:       xorw $3, {{.*}} # encoding: [0x66,0xf0
121; X32:       lock
122; X32:       xorw $3
123  %t2 = atomicrmw xor  i16* @sc16, i16 5 acquire
124; X64:       xorl
125; X64:       lock
126; X64:       cmpxchgw
127; X32:       xorl
128; X32:       lock
129; X32:       cmpxchgw
130  %t3 = atomicrmw xor  i16* @sc16, i16 %t2 acquire
131; X64:       lock
132; X64:       xorw {{.*}} # encoding: [0x66,0xf0
133; X32:       lock
134; X32:       xorw
135  ret void
136; X64:       ret
137; X32:       ret
138}
139
140define void @atomic_fetch_nand16(i16 %x) nounwind {
141; X64-LABEL:   atomic_fetch_nand16
142; X32-LABEL:   atomic_fetch_nand16
143  %t1 = atomicrmw nand i16* @sc16, i16 %x acquire
144; X64:       andl
145; X64:       notl
146; X64:       lock
147; X64:       cmpxchgw
148; X32:       andl
149; X32:       notl
150; X32:       lock
151; X32:       cmpxchgw
152  ret void
153; X64:       ret
154; X32:       ret
155}
156
157define void @atomic_fetch_max16(i16 %x) nounwind {
158; X64-LABEL:   atomic_fetch_max16
159; X32-LABEL:   atomic_fetch_max16
160  %t1 = atomicrmw max  i16* @sc16, i16 %x acquire
161; X64:       movw
162; X64:       movw
163; X64:       subw
164; X64:       cmov
165; X64:       lock
166; X64:       cmpxchgw
167
168; X32:       movw
169; X32:       movw
170; X32:       subw
171; X32:       cmov
172; X32:       lock
173; X32:       cmpxchgw
174  ret void
175; X64:       ret
176; X32:       ret
177}
178
179define void @atomic_fetch_min16(i16 %x) nounwind {
180; X64-LABEL:   atomic_fetch_min16
181; X32-LABEL:   atomic_fetch_min16
182  %t1 = atomicrmw min  i16* @sc16, i16 %x acquire
183; X64:       movw
184; X64:       movw
185; X64:       subw
186; X64:       cmov
187; X64:       lock
188; X64:       cmpxchgw
189
190; X32:       movw
191; X32:       movw
192; X32:       subw
193; X32:       cmov
194; X32:       lock
195; X32:       cmpxchgw
196  ret void
197; X64:       ret
198; X32:       ret
199}
200
201define void @atomic_fetch_umax16(i16 %x) nounwind {
202; X64-LABEL:   atomic_fetch_umax16
203; X32-LABEL:   atomic_fetch_umax16
204  %t1 = atomicrmw umax i16* @sc16, i16 %x acquire
205; X64:       movw
206; X64:       movw
207; X64:       subw
208; X64:       cmov
209; X64:       lock
210; X64:       cmpxchgw
211
212; X32:       movw
213; X32:       movw
214; X32:       subw
215; X32:       cmov
216; X32:       lock
217; X32:       cmpxchgw
218  ret void
219; X64:       ret
220; X32:       ret
221}
222
223define void @atomic_fetch_umin16(i16 %x) nounwind {
224; X64-LABEL:   atomic_fetch_umin16
225; X32-LABEL:   atomic_fetch_umin16
226  %t1 = atomicrmw umin i16* @sc16, i16 %x acquire
227; X64:       movw
228; X64:       movw
229; X64:       subw
230; X64:       cmov
231; X64:       lock
232; X64:       cmpxchgw
233
234; X32:       movw
235; X32:       movw
236; X32:       subw
237; X32:       cmov
238; X32:       lock
239; X32:       cmpxchgw
240  ret void
241; X64:       ret
242; X32:       ret
243}
244
245define void @atomic_fetch_cmpxchg16() nounwind {
246  %t1 = cmpxchg i16* @sc16, i16 0, i16 1 acquire acquire
247; X64:       lock
248; X64:       cmpxchgw
249; X32:       lock
250; X32:       cmpxchgw
251  ret void
252; X64:       ret
253; X32:       ret
254}
255
256define void @atomic_fetch_store16(i16 %x) nounwind {
257  store atomic i16 %x, i16* @sc16 release, align 4
258; X64-NOT:   lock
259; X64:       movw
260; X32-NOT:   lock
261; X32:       movw
262  ret void
263; X64:       ret
264; X32:       ret
265}
266
267define void @atomic_fetch_swap16(i16 %x) nounwind {
268  %t1 = atomicrmw xchg i16* @sc16, i16 %x acquire
269; X64-NOT:   lock
270; X64:       xchgw
271; X32-NOT:   lock
272; X32:       xchgw
273  ret void
274; X64:       ret
275; X32:       ret
276}
277
278define void @atomic_fetch_swapf16(half %x) nounwind {
279  %t1 = atomicrmw xchg half* @fsc16, half %x acquire
280; X64-NOT:   lock
281; X64:       xchgw
282; X32-NOT:   lock
283; X32:       xchgw
284  ret void
285; X64:       ret
286; X32:       ret
287}
288