xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/atomic32.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -march=x86-64 -mcpu=corei7 -verify-machineinstrs | FileCheck %s -check-prefix=WITH-CMOV
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -march=x86 -mcpu=corei7 -verify-machineinstrs | FileCheck %s -check-prefix=WITH-CMOV
3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -march=x86 -mcpu=corei7 -mattr=-cmov -verify-machineinstrs | FileCheck %s --check-prefix NOCMOV
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker@sc32 = external global i32
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_add32() nounwind {
8*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL:   atomic_fetch_add32:
9*9880d681SAndroid Build Coastguard Workerentry:
10*9880d681SAndroid Build Coastguard Worker; 32-bit
11*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw add  i32* @sc32, i32 1 acquire
12*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
13*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       incl
14*9880d681SAndroid Build Coastguard Worker  %t2 = atomicrmw add  i32* @sc32, i32 3 acquire
15*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
16*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       addl $3
17*9880d681SAndroid Build Coastguard Worker  %t3 = atomicrmw add  i32* @sc32, i32 5 acquire
18*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
19*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       xaddl
20*9880d681SAndroid Build Coastguard Worker  %t4 = atomicrmw add  i32* @sc32, i32 %t3 acquire
21*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
22*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       addl
23*9880d681SAndroid Build Coastguard Worker  ret void
24*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
25*9880d681SAndroid Build Coastguard Worker}
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_sub32() nounwind {
28*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL:   atomic_fetch_sub32:
29*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw sub  i32* @sc32, i32 1 acquire
30*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
31*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       decl
32*9880d681SAndroid Build Coastguard Worker  %t2 = atomicrmw sub  i32* @sc32, i32 3 acquire
33*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
34*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       subl $3
35*9880d681SAndroid Build Coastguard Worker  %t3 = atomicrmw sub  i32* @sc32, i32 5 acquire
36*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
37*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       xaddl
38*9880d681SAndroid Build Coastguard Worker  %t4 = atomicrmw sub  i32* @sc32, i32 %t3 acquire
39*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
40*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       subl
41*9880d681SAndroid Build Coastguard Worker  ret void
42*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
43*9880d681SAndroid Build Coastguard Worker}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_and32() nounwind {
46*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL:   atomic_fetch_and32:
47*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw and  i32* @sc32, i32 3 acquire
48*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
49*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       andl $3
50*9880d681SAndroid Build Coastguard Worker  %t2 = atomicrmw and  i32* @sc32, i32 5 acquire
51*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       andl
52*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
53*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmpxchgl
54*9880d681SAndroid Build Coastguard Worker  %t3 = atomicrmw and  i32* @sc32, i32 %t2 acquire
55*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
56*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       andl
57*9880d681SAndroid Build Coastguard Worker  ret void
58*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
59*9880d681SAndroid Build Coastguard Worker}
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_or32() nounwind {
62*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL:   atomic_fetch_or32:
63*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw or   i32* @sc32, i32 3 acquire
64*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
65*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       orl $3
66*9880d681SAndroid Build Coastguard Worker  %t2 = atomicrmw or   i32* @sc32, i32 5 acquire
67*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       orl
68*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
69*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmpxchgl
70*9880d681SAndroid Build Coastguard Worker  %t3 = atomicrmw or   i32* @sc32, i32 %t2 acquire
71*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
72*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       orl
73*9880d681SAndroid Build Coastguard Worker  ret void
74*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
75*9880d681SAndroid Build Coastguard Worker}
76*9880d681SAndroid Build Coastguard Worker
77*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_xor32() nounwind {
78*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL:   atomic_fetch_xor32:
79*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw xor  i32* @sc32, i32 3 acquire
80*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
81*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       xorl $3
82*9880d681SAndroid Build Coastguard Worker  %t2 = atomicrmw xor  i32* @sc32, i32 5 acquire
83*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       xorl
84*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
85*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmpxchgl
86*9880d681SAndroid Build Coastguard Worker  %t3 = atomicrmw xor  i32* @sc32, i32 %t2 acquire
87*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
88*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       xorl
89*9880d681SAndroid Build Coastguard Worker  ret void
90*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
91*9880d681SAndroid Build Coastguard Worker}
92*9880d681SAndroid Build Coastguard Worker
93*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_nand32(i32 %x) nounwind {
94*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL:   atomic_fetch_nand32:
95*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw nand i32* @sc32, i32 %x acquire
96*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       andl
97*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       notl
98*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
99*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmpxchgl
100*9880d681SAndroid Build Coastguard Worker  ret void
101*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
102*9880d681SAndroid Build Coastguard Worker}
103*9880d681SAndroid Build Coastguard Worker
104*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_max32(i32 %x) nounwind {
105*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL: atomic_fetch_max32:
106*9880d681SAndroid Build Coastguard Worker
107*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw max  i32* @sc32, i32 %x acquire
108*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       subl
109*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmov
110*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
111*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmpxchgl
112*9880d681SAndroid Build Coastguard Worker
113*9880d681SAndroid Build Coastguard Worker; NOCMOV:    subl
114*9880d681SAndroid Build Coastguard Worker; NOCMOV:    jge
115*9880d681SAndroid Build Coastguard Worker; NOCMOV:    lock
116*9880d681SAndroid Build Coastguard Worker; NOCMOV:    cmpxchgl
117*9880d681SAndroid Build Coastguard Worker  ret void
118*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
119*9880d681SAndroid Build Coastguard Worker; NOCMOV:    ret
120*9880d681SAndroid Build Coastguard Worker}
121*9880d681SAndroid Build Coastguard Worker
122*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_min32(i32 %x) nounwind {
123*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL: atomic_fetch_min32:
124*9880d681SAndroid Build Coastguard Worker; NOCMOV-LABEL: atomic_fetch_min32:
125*9880d681SAndroid Build Coastguard Worker
126*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw min  i32* @sc32, i32 %x acquire
127*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       subl
128*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmov
129*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
130*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmpxchgl
131*9880d681SAndroid Build Coastguard Worker
132*9880d681SAndroid Build Coastguard Worker; NOCMOV:    subl
133*9880d681SAndroid Build Coastguard Worker; NOCMOV:    jle
134*9880d681SAndroid Build Coastguard Worker; NOCMOV:    lock
135*9880d681SAndroid Build Coastguard Worker; NOCMOV:    cmpxchgl
136*9880d681SAndroid Build Coastguard Worker  ret void
137*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
138*9880d681SAndroid Build Coastguard Worker; NOCMOV:    ret
139*9880d681SAndroid Build Coastguard Worker}
140*9880d681SAndroid Build Coastguard Worker
141*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_umax32(i32 %x) nounwind {
142*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL: atomic_fetch_umax32:
143*9880d681SAndroid Build Coastguard Worker; NOCMOV-LABEL: atomic_fetch_umax32:
144*9880d681SAndroid Build Coastguard Worker
145*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw umax i32* @sc32, i32 %x acquire
146*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       subl
147*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmov
148*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
149*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmpxchgl
150*9880d681SAndroid Build Coastguard Worker
151*9880d681SAndroid Build Coastguard Worker; NOCMOV:    subl
152*9880d681SAndroid Build Coastguard Worker; NOCMOV:    ja
153*9880d681SAndroid Build Coastguard Worker; NOCMOV:    lock
154*9880d681SAndroid Build Coastguard Worker; NOCMOV:    cmpxchgl
155*9880d681SAndroid Build Coastguard Worker  ret void
156*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
157*9880d681SAndroid Build Coastguard Worker; NOCMOV:    ret
158*9880d681SAndroid Build Coastguard Worker}
159*9880d681SAndroid Build Coastguard Worker
160*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_umin32(i32 %x) nounwind {
161*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL: atomic_fetch_umin32:
162*9880d681SAndroid Build Coastguard Worker; NOCMOV-LABEL: atomic_fetch_umin32:
163*9880d681SAndroid Build Coastguard Worker
164*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw umin i32* @sc32, i32 %x acquire
165*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       subl
166*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmov
167*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
168*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmpxchgl
169*9880d681SAndroid Build Coastguard Worker
170*9880d681SAndroid Build Coastguard Worker; NOCMOV:    subl
171*9880d681SAndroid Build Coastguard Worker; NOCMOV:    jb
172*9880d681SAndroid Build Coastguard Worker; NOCMOV:    lock
173*9880d681SAndroid Build Coastguard Worker; NOCMOV:    cmpxchgl
174*9880d681SAndroid Build Coastguard Worker  ret void
175*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
176*9880d681SAndroid Build Coastguard Worker; NOCMOV:    ret
177*9880d681SAndroid Build Coastguard Worker}
178*9880d681SAndroid Build Coastguard Worker
179*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_cmpxchg32() nounwind {
180*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL: atomic_fetch_cmpxchg32:
181*9880d681SAndroid Build Coastguard Worker
182*9880d681SAndroid Build Coastguard Worker  %t1 = cmpxchg i32* @sc32, i32 0, i32 1 acquire acquire
183*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       lock
184*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       cmpxchgl
185*9880d681SAndroid Build Coastguard Worker  ret void
186*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
187*9880d681SAndroid Build Coastguard Worker}
188*9880d681SAndroid Build Coastguard Worker
189*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_store32(i32 %x) nounwind {
190*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL: atomic_fetch_store32:
191*9880d681SAndroid Build Coastguard Worker
192*9880d681SAndroid Build Coastguard Worker  store atomic i32 %x, i32* @sc32 release, align 4
193*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-NOT:   lock
194*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       movl
195*9880d681SAndroid Build Coastguard Worker  ret void
196*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
197*9880d681SAndroid Build Coastguard Worker}
198*9880d681SAndroid Build Coastguard Worker
199*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_swap32(i32 %x) nounwind {
200*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-LABEL: atomic_fetch_swap32:
201*9880d681SAndroid Build Coastguard Worker
202*9880d681SAndroid Build Coastguard Worker  %t1 = atomicrmw xchg i32* @sc32, i32 %x acquire
203*9880d681SAndroid Build Coastguard Worker; WITH-CMOV-NOT:   lock
204*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       xchgl
205*9880d681SAndroid Build Coastguard Worker  ret void
206*9880d681SAndroid Build Coastguard Worker; WITH-CMOV:       ret
207*9880d681SAndroid Build Coastguard Worker}
208