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