1; Test 32-bit atomic additions.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
4
5; Check addition of a variable.
6define i32 @f1(i32 %dummy, i32 *%src, i32 %b) {
7; CHECK-LABEL: f1:
8; CHECK: l %r2, 0(%r3)
9; CHECK: [[LABEL:\.[^:]*]]:
10; CHECK: lr %r0, %r2
11; CHECK: ar %r0, %r4
12; CHECK: cs %r2, %r0, 0(%r3)
13; CHECK: jl [[LABEL]]
14; CHECK: br %r14
15  %res = atomicrmw add i32 *%src, i32 %b seq_cst
16  ret i32 %res
17}
18
19; Check addition of 1, which can use AHI.
20define i32 @f2(i32 %dummy, i32 *%src) {
21; CHECK-LABEL: f2:
22; CHECK: l %r2, 0(%r3)
23; CHECK: [[LABEL:\.[^:]*]]:
24; CHECK: lr %r0, %r2
25; CHECK: ahi %r0, 1
26; CHECK: cs %r2, %r0, 0(%r3)
27; CHECK: jl [[LABEL]]
28; CHECK: br %r14
29  %res = atomicrmw add i32 *%src, i32 1 seq_cst
30  ret i32 %res
31}
32
33; Check the high end of the AHI range.
34define i32 @f3(i32 %dummy, i32 *%src) {
35; CHECK-LABEL: f3:
36; CHECK: ahi %r0, 32767
37; CHECK: br %r14
38  %res = atomicrmw add i32 *%src, i32 32767 seq_cst
39  ret i32 %res
40}
41
42; Check the next value up, which must use AFI.
43define i32 @f4(i32 %dummy, i32 *%src) {
44; CHECK-LABEL: f4:
45; CHECK: afi %r0, 32768
46; CHECK: br %r14
47  %res = atomicrmw add i32 *%src, i32 32768 seq_cst
48  ret i32 %res
49}
50
51; Check the high end of the AFI range.
52define i32 @f5(i32 %dummy, i32 *%src) {
53; CHECK-LABEL: f5:
54; CHECK: afi %r0, 2147483647
55; CHECK: br %r14
56  %res = atomicrmw add i32 *%src, i32 2147483647 seq_cst
57  ret i32 %res
58}
59
60; Check the next value up, which gets treated as a negative operand.
61define i32 @f6(i32 %dummy, i32 *%src) {
62; CHECK-LABEL: f6:
63; CHECK: afi %r0, -2147483648
64; CHECK: br %r14
65  %res = atomicrmw add i32 *%src, i32 2147483648 seq_cst
66  ret i32 %res
67}
68
69; Check addition of -1, which can use AHI.
70define i32 @f7(i32 %dummy, i32 *%src) {
71; CHECK-LABEL: f7:
72; CHECK: ahi %r0, -1
73; CHECK: br %r14
74  %res = atomicrmw add i32 *%src, i32 -1 seq_cst
75  ret i32 %res
76}
77
78; Check the low end of the AHI range.
79define i32 @f8(i32 %dummy, i32 *%src) {
80; CHECK-LABEL: f8:
81; CHECK: ahi %r0, -32768
82; CHECK: br %r14
83  %res = atomicrmw add i32 *%src, i32 -32768 seq_cst
84  ret i32 %res
85}
86
87; Check the next value down, which must use AFI instead.
88define i32 @f9(i32 %dummy, i32 *%src) {
89; CHECK-LABEL: f9:
90; CHECK: afi %r0, -32769
91; CHECK: br %r14
92  %res = atomicrmw add i32 *%src, i32 -32769 seq_cst
93  ret i32 %res
94}
95