[SystemZ] Add NGRK, OGRK and XGRK
[oota-llvm.git] / test / CodeGen / SystemZ / atomicrmw-and-04.ll
1 ; Test 64-bit atomic ANDs.
2 ;
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
4
5 ; Check ANDs of a variable.
6 define i64 @f1(i64 %dummy, i64 *%src, i64 %b) {
7 ; CHECK-LABEL: f1:
8 ; CHECK: lg %r2, 0(%r3)
9 ; CHECK: [[LABEL:\.[^:]*]]:
10 ; CHECK: lgr %r0, %r2
11 ; CHECK: ngr %r0, %r4
12 ; CHECK: csg %r2, %r0, 0(%r3)
13 ; CHECK: jlh [[LABEL]]
14 ; CHECK: br %r14
15   %res = atomicrmw and i64 *%src, i64 %b seq_cst
16   ret i64 %res
17 }
18
19 ; Check ANDs of 1, which must be done using a register.
20 define i64 @f2(i64 %dummy, i64 *%src) {
21 ; CHECK-LABEL: f2:
22 ; CHECK: ngr
23 ; CHECK: br %r14
24   %res = atomicrmw and i64 *%src, i64 1 seq_cst
25   ret i64 %res
26 }
27
28 ; Check the low end of the NIHF range.
29 define i64 @f3(i64 %dummy, i64 *%src) {
30 ; CHECK-LABEL: f3:
31 ; CHECK: lg %r2, 0(%r3)
32 ; CHECK: [[LABEL:\.[^:]*]]:
33 ; CHECK: lgr %r0, %r2
34 ; CHECK: nihf %r0, 0
35 ; CHECK: csg %r2, %r0, 0(%r3)
36 ; CHECK: jlh [[LABEL]]
37 ; CHECK: br %r14
38   %res = atomicrmw and i64 *%src, i64 4294967295 seq_cst
39   ret i64 %res
40 }
41
42 ; Check the next value up, which must use a register.
43 define i64 @f4(i64 %dummy, i64 *%src) {
44 ; CHECK-LABEL: f4:
45 ; CHECK: ngr
46 ; CHECK: br %r14
47   %res = atomicrmw and i64 *%src, i64 4294967296 seq_cst
48   ret i64 %res
49 }
50
51 ; Check the low end of the NIHH range.
52 define i64 @f5(i64 %dummy, i64 *%src) {
53 ; CHECK-LABEL: f5:
54 ; CHECK: nihh %r0, 0
55 ; CHECK: br %r14
56   %res = atomicrmw and i64 *%src, i64 281474976710655 seq_cst
57   ret i64 %res
58 }
59
60 ; Check the next value up, which must use a register.
61 define i64 @f6(i64 %dummy, i64 *%src) {
62 ; CHECK-LABEL: f6:
63 ; CHECK: ngr
64 ; CHECK: br %r14
65   %res = atomicrmw and i64 *%src, i64 281474976710656 seq_cst
66   ret i64 %res
67 }
68
69 ; Check the highest useful NILL value.
70 define i64 @f7(i64 %dummy, i64 *%src) {
71 ; CHECK-LABEL: f7:
72 ; CHECK: nill %r0, 65534
73 ; CHECK: br %r14
74   %res = atomicrmw and i64 *%src, i64 -2 seq_cst
75   ret i64 %res
76 }
77
78 ; Check the low end of the NILL range.
79 define i64 @f8(i64 %dummy, i64 *%src) {
80 ; CHECK-LABEL: f8:
81 ; CHECK: nill %r0, 0
82 ; CHECK: br %r14
83   %res = atomicrmw and i64 *%src, i64 -65536 seq_cst
84   ret i64 %res
85 }
86
87 ; Check the highest useful NILH value, which is one less than the above.
88 define i64 @f9(i64 %dummy, i64 *%src) {
89 ; CHECK-LABEL: f9:
90 ; CHECK: nilh %r0, 65534
91 ; CHECK: br %r14
92   %res = atomicrmw and i64 *%src, i64 -65537 seq_cst
93   ret i64 %res
94 }
95
96 ; Check the highest useful NILF value, which is one less than the above.
97 define i64 @f10(i64 %dummy, i64 *%src) {
98 ; CHECK-LABEL: f10:
99 ; CHECK: nilf %r0, 4294901758
100 ; CHECK: br %r14
101   %res = atomicrmw and i64 *%src, i64 -65538 seq_cst
102   ret i64 %res
103 }
104
105 ; Check the low end of the NILH range.
106 define i64 @f11(i64 %dummy, i64 *%src) {
107 ; CHECK-LABEL: f11:
108 ; CHECK: nilh %r0, 0
109 ; CHECK: br %r14
110   %res = atomicrmw and i64 *%src, i64 -4294901761 seq_cst
111   ret i64 %res
112 }
113
114 ; Check the low end of the NILF range.
115 define i64 @f12(i64 %dummy, i64 *%src) {
116 ; CHECK-LABEL: f12:
117 ; CHECK: nilf %r0, 0
118 ; CHECK: br %r14
119   %res = atomicrmw and i64 *%src, i64 -4294967296 seq_cst
120   ret i64 %res
121 }
122
123 ; Check the highest useful NIHL value, which is one less than the above.
124 define i64 @f13(i64 %dummy, i64 *%src) {
125 ; CHECK-LABEL: f13:
126 ; CHECK: nihl %r0, 65534
127 ; CHECK: br %r14
128   %res = atomicrmw and i64 *%src, i64 -4294967297 seq_cst
129   ret i64 %res
130 }
131
132 ; Check the low end of the NIHL range.
133 define i64 @f14(i64 %dummy, i64 *%src) {
134 ; CHECK-LABEL: f14:
135 ; CHECK: nihl %r0, 0
136 ; CHECK: br %r14
137   %res = atomicrmw and i64 *%src, i64 -281470681743361 seq_cst
138   ret i64 %res
139 }
140
141 ; Check the highest useful NIHH value, which is 1<<32 less than the above.
142 define i64 @f15(i64 %dummy, i64 *%src) {
143 ; CHECK-LABEL: f15:
144 ; CHECK: nihh %r0, 65534
145 ; CHECK: br %r14
146   %res = atomicrmw and i64 *%src, i64 -281474976710657 seq_cst
147   ret i64 %res
148 }
149
150 ; Check the highest useful NIHF value, which is 1<<32 less than the above.
151 define i64 @f16(i64 %dummy, i64 *%src) {
152 ; CHECK-LABEL: f16:
153 ; CHECK: nihf %r0, 4294901758
154 ; CHECK: br %r14
155   %res = atomicrmw and i64 *%src, i64 -281479271677953 seq_cst
156   ret i64 %res
157 }