1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3; RUN:   | FileCheck -check-prefix=RV32I %s
4
5define void @cmpxchg_i8_monotonic_monotonic(i8* %ptr, i8 %cmp, i8 %val) {
6; RV32I-LABEL: cmpxchg_i8_monotonic_monotonic:
7; RV32I:       # %bb.0:
8; RV32I-NEXT:    addi sp, sp, -16
9; RV32I-NEXT:    sw ra, 12(sp)
10; RV32I-NEXT:    sb a1, 11(sp)
11; RV32I-NEXT:    addi a1, sp, 11
12; RV32I-NEXT:    mv a3, zero
13; RV32I-NEXT:    mv a4, zero
14; RV32I-NEXT:    call __atomic_compare_exchange_1
15; RV32I-NEXT:    lw ra, 12(sp)
16; RV32I-NEXT:    addi sp, sp, 16
17; RV32I-NEXT:    ret
18  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val monotonic monotonic
19  ret void
20}
21
22define void @cmpxchg_i8_acquire_monotonic(i8* %ptr, i8 %cmp, i8 %val) {
23; RV32I-LABEL: cmpxchg_i8_acquire_monotonic:
24; RV32I:       # %bb.0:
25; RV32I-NEXT:    addi sp, sp, -16
26; RV32I-NEXT:    sw ra, 12(sp)
27; RV32I-NEXT:    sb a1, 11(sp)
28; RV32I-NEXT:    addi a1, sp, 11
29; RV32I-NEXT:    addi a3, zero, 2
30; RV32I-NEXT:    mv a4, zero
31; RV32I-NEXT:    call __atomic_compare_exchange_1
32; RV32I-NEXT:    lw ra, 12(sp)
33; RV32I-NEXT:    addi sp, sp, 16
34; RV32I-NEXT:    ret
35  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val acquire monotonic
36  ret void
37}
38
39define void @cmpxchg_i8_acquire_acquire(i8* %ptr, i8 %cmp, i8 %val) {
40; RV32I-LABEL: cmpxchg_i8_acquire_acquire:
41; RV32I:       # %bb.0:
42; RV32I-NEXT:    addi sp, sp, -16
43; RV32I-NEXT:    sw ra, 12(sp)
44; RV32I-NEXT:    sb a1, 11(sp)
45; RV32I-NEXT:    addi a1, sp, 11
46; RV32I-NEXT:    addi a3, zero, 2
47; RV32I-NEXT:    mv a4, a3
48; RV32I-NEXT:    call __atomic_compare_exchange_1
49; RV32I-NEXT:    lw ra, 12(sp)
50; RV32I-NEXT:    addi sp, sp, 16
51; RV32I-NEXT:    ret
52  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val acquire acquire
53  ret void
54}
55
56define void @cmpxchg_i8_release_monotonic(i8* %ptr, i8 %cmp, i8 %val) {
57; RV32I-LABEL: cmpxchg_i8_release_monotonic:
58; RV32I:       # %bb.0:
59; RV32I-NEXT:    addi sp, sp, -16
60; RV32I-NEXT:    sw ra, 12(sp)
61; RV32I-NEXT:    sb a1, 11(sp)
62; RV32I-NEXT:    addi a1, sp, 11
63; RV32I-NEXT:    addi a3, zero, 3
64; RV32I-NEXT:    mv a4, zero
65; RV32I-NEXT:    call __atomic_compare_exchange_1
66; RV32I-NEXT:    lw ra, 12(sp)
67; RV32I-NEXT:    addi sp, sp, 16
68; RV32I-NEXT:    ret
69  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val release monotonic
70  ret void
71}
72
73define void @cmpxchg_i8_release_acquire(i8* %ptr, i8 %cmp, i8 %val) {
74; RV32I-LABEL: cmpxchg_i8_release_acquire:
75; RV32I:       # %bb.0:
76; RV32I-NEXT:    addi sp, sp, -16
77; RV32I-NEXT:    sw ra, 12(sp)
78; RV32I-NEXT:    sb a1, 11(sp)
79; RV32I-NEXT:    addi a1, sp, 11
80; RV32I-NEXT:    addi a3, zero, 3
81; RV32I-NEXT:    addi a4, zero, 2
82; RV32I-NEXT:    call __atomic_compare_exchange_1
83; RV32I-NEXT:    lw ra, 12(sp)
84; RV32I-NEXT:    addi sp, sp, 16
85; RV32I-NEXT:    ret
86  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val release acquire
87  ret void
88}
89
90define void @cmpxchg_i8_acq_rel_monotonic(i8* %ptr, i8 %cmp, i8 %val) {
91; RV32I-LABEL: cmpxchg_i8_acq_rel_monotonic:
92; RV32I:       # %bb.0:
93; RV32I-NEXT:    addi sp, sp, -16
94; RV32I-NEXT:    sw ra, 12(sp)
95; RV32I-NEXT:    sb a1, 11(sp)
96; RV32I-NEXT:    addi a1, sp, 11
97; RV32I-NEXT:    addi a3, zero, 4
98; RV32I-NEXT:    mv a4, zero
99; RV32I-NEXT:    call __atomic_compare_exchange_1
100; RV32I-NEXT:    lw ra, 12(sp)
101; RV32I-NEXT:    addi sp, sp, 16
102; RV32I-NEXT:    ret
103  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val acq_rel monotonic
104  ret void
105}
106
107define void @cmpxchg_i8_acq_rel_acquire(i8* %ptr, i8 %cmp, i8 %val) {
108; RV32I-LABEL: cmpxchg_i8_acq_rel_acquire:
109; RV32I:       # %bb.0:
110; RV32I-NEXT:    addi sp, sp, -16
111; RV32I-NEXT:    sw ra, 12(sp)
112; RV32I-NEXT:    sb a1, 11(sp)
113; RV32I-NEXT:    addi a1, sp, 11
114; RV32I-NEXT:    addi a3, zero, 4
115; RV32I-NEXT:    addi a4, zero, 2
116; RV32I-NEXT:    call __atomic_compare_exchange_1
117; RV32I-NEXT:    lw ra, 12(sp)
118; RV32I-NEXT:    addi sp, sp, 16
119; RV32I-NEXT:    ret
120  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val acq_rel acquire
121  ret void
122}
123
124define void @cmpxchg_i8_seq_cst_monotonic(i8* %ptr, i8 %cmp, i8 %val) {
125; RV32I-LABEL: cmpxchg_i8_seq_cst_monotonic:
126; RV32I:       # %bb.0:
127; RV32I-NEXT:    addi sp, sp, -16
128; RV32I-NEXT:    sw ra, 12(sp)
129; RV32I-NEXT:    sb a1, 11(sp)
130; RV32I-NEXT:    addi a1, sp, 11
131; RV32I-NEXT:    addi a3, zero, 5
132; RV32I-NEXT:    mv a4, zero
133; RV32I-NEXT:    call __atomic_compare_exchange_1
134; RV32I-NEXT:    lw ra, 12(sp)
135; RV32I-NEXT:    addi sp, sp, 16
136; RV32I-NEXT:    ret
137  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val seq_cst monotonic
138  ret void
139}
140
141define void @cmpxchg_i8_seq_cst_acquire(i8* %ptr, i8 %cmp, i8 %val) {
142; RV32I-LABEL: cmpxchg_i8_seq_cst_acquire:
143; RV32I:       # %bb.0:
144; RV32I-NEXT:    addi sp, sp, -16
145; RV32I-NEXT:    sw ra, 12(sp)
146; RV32I-NEXT:    sb a1, 11(sp)
147; RV32I-NEXT:    addi a1, sp, 11
148; RV32I-NEXT:    addi a3, zero, 5
149; RV32I-NEXT:    addi a4, zero, 2
150; RV32I-NEXT:    call __atomic_compare_exchange_1
151; RV32I-NEXT:    lw ra, 12(sp)
152; RV32I-NEXT:    addi sp, sp, 16
153; RV32I-NEXT:    ret
154  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val seq_cst acquire
155  ret void
156}
157
158define void @cmpxchg_i8_seq_cst_seq_cst(i8* %ptr, i8 %cmp, i8 %val) {
159; RV32I-LABEL: cmpxchg_i8_seq_cst_seq_cst:
160; RV32I:       # %bb.0:
161; RV32I-NEXT:    addi sp, sp, -16
162; RV32I-NEXT:    sw ra, 12(sp)
163; RV32I-NEXT:    sb a1, 11(sp)
164; RV32I-NEXT:    addi a1, sp, 11
165; RV32I-NEXT:    addi a3, zero, 5
166; RV32I-NEXT:    mv a4, a3
167; RV32I-NEXT:    call __atomic_compare_exchange_1
168; RV32I-NEXT:    lw ra, 12(sp)
169; RV32I-NEXT:    addi sp, sp, 16
170; RV32I-NEXT:    ret
171  %res = cmpxchg i8* %ptr, i8 %cmp, i8 %val seq_cst seq_cst
172  ret void
173}
174
175define void @cmpxchg_i16_monotonic_monotonic(i16* %ptr, i16 %cmp, i16 %val) {
176; RV32I-LABEL: cmpxchg_i16_monotonic_monotonic:
177; RV32I:       # %bb.0:
178; RV32I-NEXT:    addi sp, sp, -16
179; RV32I-NEXT:    sw ra, 12(sp)
180; RV32I-NEXT:    sh a1, 10(sp)
181; RV32I-NEXT:    addi a1, sp, 10
182; RV32I-NEXT:    mv a3, zero
183; RV32I-NEXT:    mv a4, zero
184; RV32I-NEXT:    call __atomic_compare_exchange_2
185; RV32I-NEXT:    lw ra, 12(sp)
186; RV32I-NEXT:    addi sp, sp, 16
187; RV32I-NEXT:    ret
188  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val monotonic monotonic
189  ret void
190}
191
192define void @cmpxchg_i16_acquire_monotonic(i16* %ptr, i16 %cmp, i16 %val) {
193; RV32I-LABEL: cmpxchg_i16_acquire_monotonic:
194; RV32I:       # %bb.0:
195; RV32I-NEXT:    addi sp, sp, -16
196; RV32I-NEXT:    sw ra, 12(sp)
197; RV32I-NEXT:    sh a1, 10(sp)
198; RV32I-NEXT:    addi a1, sp, 10
199; RV32I-NEXT:    addi a3, zero, 2
200; RV32I-NEXT:    mv a4, zero
201; RV32I-NEXT:    call __atomic_compare_exchange_2
202; RV32I-NEXT:    lw ra, 12(sp)
203; RV32I-NEXT:    addi sp, sp, 16
204; RV32I-NEXT:    ret
205  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val acquire monotonic
206  ret void
207}
208
209define void @cmpxchg_i16_acquire_acquire(i16* %ptr, i16 %cmp, i16 %val) {
210; RV32I-LABEL: cmpxchg_i16_acquire_acquire:
211; RV32I:       # %bb.0:
212; RV32I-NEXT:    addi sp, sp, -16
213; RV32I-NEXT:    sw ra, 12(sp)
214; RV32I-NEXT:    sh a1, 10(sp)
215; RV32I-NEXT:    addi a1, sp, 10
216; RV32I-NEXT:    addi a3, zero, 2
217; RV32I-NEXT:    mv a4, a3
218; RV32I-NEXT:    call __atomic_compare_exchange_2
219; RV32I-NEXT:    lw ra, 12(sp)
220; RV32I-NEXT:    addi sp, sp, 16
221; RV32I-NEXT:    ret
222  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val acquire acquire
223  ret void
224}
225
226define void @cmpxchg_i16_release_monotonic(i16* %ptr, i16 %cmp, i16 %val) {
227; RV32I-LABEL: cmpxchg_i16_release_monotonic:
228; RV32I:       # %bb.0:
229; RV32I-NEXT:    addi sp, sp, -16
230; RV32I-NEXT:    sw ra, 12(sp)
231; RV32I-NEXT:    sh a1, 10(sp)
232; RV32I-NEXT:    addi a1, sp, 10
233; RV32I-NEXT:    addi a3, zero, 3
234; RV32I-NEXT:    mv a4, zero
235; RV32I-NEXT:    call __atomic_compare_exchange_2
236; RV32I-NEXT:    lw ra, 12(sp)
237; RV32I-NEXT:    addi sp, sp, 16
238; RV32I-NEXT:    ret
239  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val release monotonic
240  ret void
241}
242
243define void @cmpxchg_i16_release_acquire(i16* %ptr, i16 %cmp, i16 %val) {
244; RV32I-LABEL: cmpxchg_i16_release_acquire:
245; RV32I:       # %bb.0:
246; RV32I-NEXT:    addi sp, sp, -16
247; RV32I-NEXT:    sw ra, 12(sp)
248; RV32I-NEXT:    sh a1, 10(sp)
249; RV32I-NEXT:    addi a1, sp, 10
250; RV32I-NEXT:    addi a3, zero, 3
251; RV32I-NEXT:    addi a4, zero, 2
252; RV32I-NEXT:    call __atomic_compare_exchange_2
253; RV32I-NEXT:    lw ra, 12(sp)
254; RV32I-NEXT:    addi sp, sp, 16
255; RV32I-NEXT:    ret
256  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val release acquire
257  ret void
258}
259
260define void @cmpxchg_i16_acq_rel_monotonic(i16* %ptr, i16 %cmp, i16 %val) {
261; RV32I-LABEL: cmpxchg_i16_acq_rel_monotonic:
262; RV32I:       # %bb.0:
263; RV32I-NEXT:    addi sp, sp, -16
264; RV32I-NEXT:    sw ra, 12(sp)
265; RV32I-NEXT:    sh a1, 10(sp)
266; RV32I-NEXT:    addi a1, sp, 10
267; RV32I-NEXT:    addi a3, zero, 4
268; RV32I-NEXT:    mv a4, zero
269; RV32I-NEXT:    call __atomic_compare_exchange_2
270; RV32I-NEXT:    lw ra, 12(sp)
271; RV32I-NEXT:    addi sp, sp, 16
272; RV32I-NEXT:    ret
273  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val acq_rel monotonic
274  ret void
275}
276
277define void @cmpxchg_i16_acq_rel_acquire(i16* %ptr, i16 %cmp, i16 %val) {
278; RV32I-LABEL: cmpxchg_i16_acq_rel_acquire:
279; RV32I:       # %bb.0:
280; RV32I-NEXT:    addi sp, sp, -16
281; RV32I-NEXT:    sw ra, 12(sp)
282; RV32I-NEXT:    sh a1, 10(sp)
283; RV32I-NEXT:    addi a1, sp, 10
284; RV32I-NEXT:    addi a3, zero, 4
285; RV32I-NEXT:    addi a4, zero, 2
286; RV32I-NEXT:    call __atomic_compare_exchange_2
287; RV32I-NEXT:    lw ra, 12(sp)
288; RV32I-NEXT:    addi sp, sp, 16
289; RV32I-NEXT:    ret
290  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val acq_rel acquire
291  ret void
292}
293
294define void @cmpxchg_i16_seq_cst_monotonic(i16* %ptr, i16 %cmp, i16 %val) {
295; RV32I-LABEL: cmpxchg_i16_seq_cst_monotonic:
296; RV32I:       # %bb.0:
297; RV32I-NEXT:    addi sp, sp, -16
298; RV32I-NEXT:    sw ra, 12(sp)
299; RV32I-NEXT:    sh a1, 10(sp)
300; RV32I-NEXT:    addi a1, sp, 10
301; RV32I-NEXT:    addi a3, zero, 5
302; RV32I-NEXT:    mv a4, zero
303; RV32I-NEXT:    call __atomic_compare_exchange_2
304; RV32I-NEXT:    lw ra, 12(sp)
305; RV32I-NEXT:    addi sp, sp, 16
306; RV32I-NEXT:    ret
307  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val seq_cst monotonic
308  ret void
309}
310
311define void @cmpxchg_i16_seq_cst_acquire(i16* %ptr, i16 %cmp, i16 %val) {
312; RV32I-LABEL: cmpxchg_i16_seq_cst_acquire:
313; RV32I:       # %bb.0:
314; RV32I-NEXT:    addi sp, sp, -16
315; RV32I-NEXT:    sw ra, 12(sp)
316; RV32I-NEXT:    sh a1, 10(sp)
317; RV32I-NEXT:    addi a1, sp, 10
318; RV32I-NEXT:    addi a3, zero, 5
319; RV32I-NEXT:    addi a4, zero, 2
320; RV32I-NEXT:    call __atomic_compare_exchange_2
321; RV32I-NEXT:    lw ra, 12(sp)
322; RV32I-NEXT:    addi sp, sp, 16
323; RV32I-NEXT:    ret
324  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val seq_cst acquire
325  ret void
326}
327
328define void @cmpxchg_i16_seq_cst_seq_cst(i16* %ptr, i16 %cmp, i16 %val) {
329; RV32I-LABEL: cmpxchg_i16_seq_cst_seq_cst:
330; RV32I:       # %bb.0:
331; RV32I-NEXT:    addi sp, sp, -16
332; RV32I-NEXT:    sw ra, 12(sp)
333; RV32I-NEXT:    sh a1, 10(sp)
334; RV32I-NEXT:    addi a1, sp, 10
335; RV32I-NEXT:    addi a3, zero, 5
336; RV32I-NEXT:    mv a4, a3
337; RV32I-NEXT:    call __atomic_compare_exchange_2
338; RV32I-NEXT:    lw ra, 12(sp)
339; RV32I-NEXT:    addi sp, sp, 16
340; RV32I-NEXT:    ret
341  %res = cmpxchg i16* %ptr, i16 %cmp, i16 %val seq_cst seq_cst
342  ret void
343}
344
345define void @cmpxchg_i32_monotonic_monotonic(i32* %ptr, i32 %cmp, i32 %val) {
346; RV32I-LABEL: cmpxchg_i32_monotonic_monotonic:
347; RV32I:       # %bb.0:
348; RV32I-NEXT:    addi sp, sp, -16
349; RV32I-NEXT:    sw ra, 12(sp)
350; RV32I-NEXT:    sw a1, 8(sp)
351; RV32I-NEXT:    addi a1, sp, 8
352; RV32I-NEXT:    mv a3, zero
353; RV32I-NEXT:    mv a4, zero
354; RV32I-NEXT:    call __atomic_compare_exchange_4
355; RV32I-NEXT:    lw ra, 12(sp)
356; RV32I-NEXT:    addi sp, sp, 16
357; RV32I-NEXT:    ret
358  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val monotonic monotonic
359  ret void
360}
361
362define void @cmpxchg_i32_acquire_monotonic(i32* %ptr, i32 %cmp, i32 %val) {
363; RV32I-LABEL: cmpxchg_i32_acquire_monotonic:
364; RV32I:       # %bb.0:
365; RV32I-NEXT:    addi sp, sp, -16
366; RV32I-NEXT:    sw ra, 12(sp)
367; RV32I-NEXT:    sw a1, 8(sp)
368; RV32I-NEXT:    addi a1, sp, 8
369; RV32I-NEXT:    addi a3, zero, 2
370; RV32I-NEXT:    mv a4, zero
371; RV32I-NEXT:    call __atomic_compare_exchange_4
372; RV32I-NEXT:    lw ra, 12(sp)
373; RV32I-NEXT:    addi sp, sp, 16
374; RV32I-NEXT:    ret
375  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val acquire monotonic
376  ret void
377}
378
379define void @cmpxchg_i32_acquire_acquire(i32* %ptr, i32 %cmp, i32 %val) {
380; RV32I-LABEL: cmpxchg_i32_acquire_acquire:
381; RV32I:       # %bb.0:
382; RV32I-NEXT:    addi sp, sp, -16
383; RV32I-NEXT:    sw ra, 12(sp)
384; RV32I-NEXT:    sw a1, 8(sp)
385; RV32I-NEXT:    addi a1, sp, 8
386; RV32I-NEXT:    addi a3, zero, 2
387; RV32I-NEXT:    mv a4, a3
388; RV32I-NEXT:    call __atomic_compare_exchange_4
389; RV32I-NEXT:    lw ra, 12(sp)
390; RV32I-NEXT:    addi sp, sp, 16
391; RV32I-NEXT:    ret
392  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val acquire acquire
393  ret void
394}
395
396define void @cmpxchg_i32_release_monotonic(i32* %ptr, i32 %cmp, i32 %val) {
397; RV32I-LABEL: cmpxchg_i32_release_monotonic:
398; RV32I:       # %bb.0:
399; RV32I-NEXT:    addi sp, sp, -16
400; RV32I-NEXT:    sw ra, 12(sp)
401; RV32I-NEXT:    sw a1, 8(sp)
402; RV32I-NEXT:    addi a1, sp, 8
403; RV32I-NEXT:    addi a3, zero, 3
404; RV32I-NEXT:    mv a4, zero
405; RV32I-NEXT:    call __atomic_compare_exchange_4
406; RV32I-NEXT:    lw ra, 12(sp)
407; RV32I-NEXT:    addi sp, sp, 16
408; RV32I-NEXT:    ret
409  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val release monotonic
410  ret void
411}
412
413define void @cmpxchg_i32_release_acquire(i32* %ptr, i32 %cmp, i32 %val) {
414; RV32I-LABEL: cmpxchg_i32_release_acquire:
415; RV32I:       # %bb.0:
416; RV32I-NEXT:    addi sp, sp, -16
417; RV32I-NEXT:    sw ra, 12(sp)
418; RV32I-NEXT:    sw a1, 8(sp)
419; RV32I-NEXT:    addi a1, sp, 8
420; RV32I-NEXT:    addi a3, zero, 3
421; RV32I-NEXT:    addi a4, zero, 2
422; RV32I-NEXT:    call __atomic_compare_exchange_4
423; RV32I-NEXT:    lw ra, 12(sp)
424; RV32I-NEXT:    addi sp, sp, 16
425; RV32I-NEXT:    ret
426  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val release acquire
427  ret void
428}
429
430define void @cmpxchg_i32_acq_rel_monotonic(i32* %ptr, i32 %cmp, i32 %val) {
431; RV32I-LABEL: cmpxchg_i32_acq_rel_monotonic:
432; RV32I:       # %bb.0:
433; RV32I-NEXT:    addi sp, sp, -16
434; RV32I-NEXT:    sw ra, 12(sp)
435; RV32I-NEXT:    sw a1, 8(sp)
436; RV32I-NEXT:    addi a1, sp, 8
437; RV32I-NEXT:    addi a3, zero, 4
438; RV32I-NEXT:    mv a4, zero
439; RV32I-NEXT:    call __atomic_compare_exchange_4
440; RV32I-NEXT:    lw ra, 12(sp)
441; RV32I-NEXT:    addi sp, sp, 16
442; RV32I-NEXT:    ret
443  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val acq_rel monotonic
444  ret void
445}
446
447define void @cmpxchg_i32_acq_rel_acquire(i32* %ptr, i32 %cmp, i32 %val) {
448; RV32I-LABEL: cmpxchg_i32_acq_rel_acquire:
449; RV32I:       # %bb.0:
450; RV32I-NEXT:    addi sp, sp, -16
451; RV32I-NEXT:    sw ra, 12(sp)
452; RV32I-NEXT:    sw a1, 8(sp)
453; RV32I-NEXT:    addi a1, sp, 8
454; RV32I-NEXT:    addi a3, zero, 4
455; RV32I-NEXT:    addi a4, zero, 2
456; RV32I-NEXT:    call __atomic_compare_exchange_4
457; RV32I-NEXT:    lw ra, 12(sp)
458; RV32I-NEXT:    addi sp, sp, 16
459; RV32I-NEXT:    ret
460  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val acq_rel acquire
461  ret void
462}
463
464define void @cmpxchg_i32_seq_cst_monotonic(i32* %ptr, i32 %cmp, i32 %val) {
465; RV32I-LABEL: cmpxchg_i32_seq_cst_monotonic:
466; RV32I:       # %bb.0:
467; RV32I-NEXT:    addi sp, sp, -16
468; RV32I-NEXT:    sw ra, 12(sp)
469; RV32I-NEXT:    sw a1, 8(sp)
470; RV32I-NEXT:    addi a1, sp, 8
471; RV32I-NEXT:    addi a3, zero, 5
472; RV32I-NEXT:    mv a4, zero
473; RV32I-NEXT:    call __atomic_compare_exchange_4
474; RV32I-NEXT:    lw ra, 12(sp)
475; RV32I-NEXT:    addi sp, sp, 16
476; RV32I-NEXT:    ret
477  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val seq_cst monotonic
478  ret void
479}
480
481define void @cmpxchg_i32_seq_cst_acquire(i32* %ptr, i32 %cmp, i32 %val) {
482; RV32I-LABEL: cmpxchg_i32_seq_cst_acquire:
483; RV32I:       # %bb.0:
484; RV32I-NEXT:    addi sp, sp, -16
485; RV32I-NEXT:    sw ra, 12(sp)
486; RV32I-NEXT:    sw a1, 8(sp)
487; RV32I-NEXT:    addi a1, sp, 8
488; RV32I-NEXT:    addi a3, zero, 5
489; RV32I-NEXT:    addi a4, zero, 2
490; RV32I-NEXT:    call __atomic_compare_exchange_4
491; RV32I-NEXT:    lw ra, 12(sp)
492; RV32I-NEXT:    addi sp, sp, 16
493; RV32I-NEXT:    ret
494  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val seq_cst acquire
495  ret void
496}
497
498define void @cmpxchg_i32_seq_cst_seq_cst(i32* %ptr, i32 %cmp, i32 %val) {
499; RV32I-LABEL: cmpxchg_i32_seq_cst_seq_cst:
500; RV32I:       # %bb.0:
501; RV32I-NEXT:    addi sp, sp, -16
502; RV32I-NEXT:    sw ra, 12(sp)
503; RV32I-NEXT:    sw a1, 8(sp)
504; RV32I-NEXT:    addi a1, sp, 8
505; RV32I-NEXT:    addi a3, zero, 5
506; RV32I-NEXT:    mv a4, a3
507; RV32I-NEXT:    call __atomic_compare_exchange_4
508; RV32I-NEXT:    lw ra, 12(sp)
509; RV32I-NEXT:    addi sp, sp, 16
510; RV32I-NEXT:    ret
511  %res = cmpxchg i32* %ptr, i32 %cmp, i32 %val seq_cst seq_cst
512  ret void
513}
514
515define void @cmpxchg_i64_monotonic_monotonic(i64* %ptr, i64 %cmp, i64 %val) {
516; RV32I-LABEL: cmpxchg_i64_monotonic_monotonic:
517; RV32I:       # %bb.0:
518; RV32I-NEXT:    addi sp, sp, -16
519; RV32I-NEXT:    sw ra, 12(sp)
520; RV32I-NEXT:    sw a2, 4(sp)
521; RV32I-NEXT:    sw a1, 0(sp)
522; RV32I-NEXT:    mv a1, sp
523; RV32I-NEXT:    mv a2, a3
524; RV32I-NEXT:    mv a3, a4
525; RV32I-NEXT:    mv a4, zero
526; RV32I-NEXT:    mv a5, zero
527; RV32I-NEXT:    call __atomic_compare_exchange_8
528; RV32I-NEXT:    lw ra, 12(sp)
529; RV32I-NEXT:    addi sp, sp, 16
530; RV32I-NEXT:    ret
531  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val monotonic monotonic
532  ret void
533}
534
535define void @cmpxchg_i64_acquire_monotonic(i64* %ptr, i64 %cmp, i64 %val) {
536; RV32I-LABEL: cmpxchg_i64_acquire_monotonic:
537; RV32I:       # %bb.0:
538; RV32I-NEXT:    addi sp, sp, -16
539; RV32I-NEXT:    sw ra, 12(sp)
540; RV32I-NEXT:    sw a2, 4(sp)
541; RV32I-NEXT:    sw a1, 0(sp)
542; RV32I-NEXT:    mv a1, sp
543; RV32I-NEXT:    addi a5, zero, 2
544; RV32I-NEXT:    mv a2, a3
545; RV32I-NEXT:    mv a3, a4
546; RV32I-NEXT:    mv a4, a5
547; RV32I-NEXT:    mv a5, zero
548; RV32I-NEXT:    call __atomic_compare_exchange_8
549; RV32I-NEXT:    lw ra, 12(sp)
550; RV32I-NEXT:    addi sp, sp, 16
551; RV32I-NEXT:    ret
552  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val acquire monotonic
553  ret void
554}
555
556define void @cmpxchg_i64_acquire_acquire(i64* %ptr, i64 %cmp, i64 %val) {
557; RV32I-LABEL: cmpxchg_i64_acquire_acquire:
558; RV32I:       # %bb.0:
559; RV32I-NEXT:    addi sp, sp, -16
560; RV32I-NEXT:    sw ra, 12(sp)
561; RV32I-NEXT:    sw a2, 4(sp)
562; RV32I-NEXT:    sw a1, 0(sp)
563; RV32I-NEXT:    mv a1, sp
564; RV32I-NEXT:    addi a5, zero, 2
565; RV32I-NEXT:    mv a2, a3
566; RV32I-NEXT:    mv a3, a4
567; RV32I-NEXT:    mv a4, a5
568; RV32I-NEXT:    call __atomic_compare_exchange_8
569; RV32I-NEXT:    lw ra, 12(sp)
570; RV32I-NEXT:    addi sp, sp, 16
571; RV32I-NEXT:    ret
572  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val acquire acquire
573  ret void
574}
575
576define void @cmpxchg_i64_release_monotonic(i64* %ptr, i64 %cmp, i64 %val) {
577; RV32I-LABEL: cmpxchg_i64_release_monotonic:
578; RV32I:       # %bb.0:
579; RV32I-NEXT:    addi sp, sp, -16
580; RV32I-NEXT:    sw ra, 12(sp)
581; RV32I-NEXT:    sw a2, 4(sp)
582; RV32I-NEXT:    sw a1, 0(sp)
583; RV32I-NEXT:    mv a1, sp
584; RV32I-NEXT:    addi a5, zero, 3
585; RV32I-NEXT:    mv a2, a3
586; RV32I-NEXT:    mv a3, a4
587; RV32I-NEXT:    mv a4, a5
588; RV32I-NEXT:    mv a5, zero
589; RV32I-NEXT:    call __atomic_compare_exchange_8
590; RV32I-NEXT:    lw ra, 12(sp)
591; RV32I-NEXT:    addi sp, sp, 16
592; RV32I-NEXT:    ret
593  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val release monotonic
594  ret void
595}
596
597define void @cmpxchg_i64_release_acquire(i64* %ptr, i64 %cmp, i64 %val) {
598; RV32I-LABEL: cmpxchg_i64_release_acquire:
599; RV32I:       # %bb.0:
600; RV32I-NEXT:    addi sp, sp, -16
601; RV32I-NEXT:    sw ra, 12(sp)
602; RV32I-NEXT:    sw a2, 4(sp)
603; RV32I-NEXT:    sw a1, 0(sp)
604; RV32I-NEXT:    mv a1, sp
605; RV32I-NEXT:    addi a6, zero, 3
606; RV32I-NEXT:    addi a5, zero, 2
607; RV32I-NEXT:    mv a2, a3
608; RV32I-NEXT:    mv a3, a4
609; RV32I-NEXT:    mv a4, a6
610; RV32I-NEXT:    call __atomic_compare_exchange_8
611; RV32I-NEXT:    lw ra, 12(sp)
612; RV32I-NEXT:    addi sp, sp, 16
613; RV32I-NEXT:    ret
614  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val release acquire
615  ret void
616}
617
618define void @cmpxchg_i64_acq_rel_monotonic(i64* %ptr, i64 %cmp, i64 %val) {
619; RV32I-LABEL: cmpxchg_i64_acq_rel_monotonic:
620; RV32I:       # %bb.0:
621; RV32I-NEXT:    addi sp, sp, -16
622; RV32I-NEXT:    sw ra, 12(sp)
623; RV32I-NEXT:    sw a2, 4(sp)
624; RV32I-NEXT:    sw a1, 0(sp)
625; RV32I-NEXT:    mv a1, sp
626; RV32I-NEXT:    addi a5, zero, 4
627; RV32I-NEXT:    mv a2, a3
628; RV32I-NEXT:    mv a3, a4
629; RV32I-NEXT:    mv a4, a5
630; RV32I-NEXT:    mv a5, zero
631; RV32I-NEXT:    call __atomic_compare_exchange_8
632; RV32I-NEXT:    lw ra, 12(sp)
633; RV32I-NEXT:    addi sp, sp, 16
634; RV32I-NEXT:    ret
635  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val acq_rel monotonic
636  ret void
637}
638
639define void @cmpxchg_i64_acq_rel_acquire(i64* %ptr, i64 %cmp, i64 %val) {
640; RV32I-LABEL: cmpxchg_i64_acq_rel_acquire:
641; RV32I:       # %bb.0:
642; RV32I-NEXT:    addi sp, sp, -16
643; RV32I-NEXT:    sw ra, 12(sp)
644; RV32I-NEXT:    sw a2, 4(sp)
645; RV32I-NEXT:    sw a1, 0(sp)
646; RV32I-NEXT:    mv a1, sp
647; RV32I-NEXT:    addi a6, zero, 4
648; RV32I-NEXT:    addi a5, zero, 2
649; RV32I-NEXT:    mv a2, a3
650; RV32I-NEXT:    mv a3, a4
651; RV32I-NEXT:    mv a4, a6
652; RV32I-NEXT:    call __atomic_compare_exchange_8
653; RV32I-NEXT:    lw ra, 12(sp)
654; RV32I-NEXT:    addi sp, sp, 16
655; RV32I-NEXT:    ret
656  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val acq_rel acquire
657  ret void
658}
659
660define void @cmpxchg_i64_seq_cst_monotonic(i64* %ptr, i64 %cmp, i64 %val) {
661; RV32I-LABEL: cmpxchg_i64_seq_cst_monotonic:
662; RV32I:       # %bb.0:
663; RV32I-NEXT:    addi sp, sp, -16
664; RV32I-NEXT:    sw ra, 12(sp)
665; RV32I-NEXT:    sw a2, 4(sp)
666; RV32I-NEXT:    sw a1, 0(sp)
667; RV32I-NEXT:    mv a1, sp
668; RV32I-NEXT:    addi a5, zero, 5
669; RV32I-NEXT:    mv a2, a3
670; RV32I-NEXT:    mv a3, a4
671; RV32I-NEXT:    mv a4, a5
672; RV32I-NEXT:    mv a5, zero
673; RV32I-NEXT:    call __atomic_compare_exchange_8
674; RV32I-NEXT:    lw ra, 12(sp)
675; RV32I-NEXT:    addi sp, sp, 16
676; RV32I-NEXT:    ret
677  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val seq_cst monotonic
678  ret void
679}
680
681define void @cmpxchg_i64_seq_cst_acquire(i64* %ptr, i64 %cmp, i64 %val) {
682; RV32I-LABEL: cmpxchg_i64_seq_cst_acquire:
683; RV32I:       # %bb.0:
684; RV32I-NEXT:    addi sp, sp, -16
685; RV32I-NEXT:    sw ra, 12(sp)
686; RV32I-NEXT:    sw a2, 4(sp)
687; RV32I-NEXT:    sw a1, 0(sp)
688; RV32I-NEXT:    mv a1, sp
689; RV32I-NEXT:    addi a6, zero, 5
690; RV32I-NEXT:    addi a5, zero, 2
691; RV32I-NEXT:    mv a2, a3
692; RV32I-NEXT:    mv a3, a4
693; RV32I-NEXT:    mv a4, a6
694; RV32I-NEXT:    call __atomic_compare_exchange_8
695; RV32I-NEXT:    lw ra, 12(sp)
696; RV32I-NEXT:    addi sp, sp, 16
697; RV32I-NEXT:    ret
698  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val seq_cst acquire
699  ret void
700}
701
702define void @cmpxchg_i64_seq_cst_seq_cst(i64* %ptr, i64 %cmp, i64 %val) {
703; RV32I-LABEL: cmpxchg_i64_seq_cst_seq_cst:
704; RV32I:       # %bb.0:
705; RV32I-NEXT:    addi sp, sp, -16
706; RV32I-NEXT:    sw ra, 12(sp)
707; RV32I-NEXT:    sw a2, 4(sp)
708; RV32I-NEXT:    sw a1, 0(sp)
709; RV32I-NEXT:    mv a1, sp
710; RV32I-NEXT:    addi a5, zero, 5
711; RV32I-NEXT:    mv a2, a3
712; RV32I-NEXT:    mv a3, a4
713; RV32I-NEXT:    mv a4, a5
714; RV32I-NEXT:    call __atomic_compare_exchange_8
715; RV32I-NEXT:    lw ra, 12(sp)
716; RV32I-NEXT:    addi sp, sp, 16
717; RV32I-NEXT:    ret
718  %res = cmpxchg i64* %ptr, i64 %cmp, i64 %val seq_cst seq_cst
719  ret void
720}
721