1 ; Test 32-bit ANDs in which the second operand is constant.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
5 ; ANDs with 1 can use NILF.
6 define i32 @f1(i32 %a) {
14 ; ...but RISBLG is available as a three-address form.
15 define i32 @f2(i32 %a, i32 %b) {
17 ; CHECK: risblg %r2, %r3, 31, 159, 0
24 define i32 @f3(i32 %a, i32 %b) {
26 ; CHECK: risblg %r2, %r3, 29, 157, 0
32 ; ANDs with 5 must use NILF.
33 define i32 @f4(i32 %a) {
41 ; ...a single RISBLG isn't enough.
42 define i32 @f5(i32 %a, i32 %b) {
50 ; Check the highest 16-bit constant that must be handled by NILF.
51 define i32 @f6(i32 %a) {
53 ; CHECK: nilf %r2, 65533
55 %and = and i32 %a, 65533
59 ; ...a single RISBLG isn't enough.
60 define i32 @f7(i32 %a, i32 %b) {
64 %and = and i32 %b, 65533
68 ; Check the next highest value, which can use NILF.
69 define i32 @f8(i32 %a) {
71 ; CHECK: nilf %r2, 65534
73 %and = and i32 %a, 65534
77 ; ...although the three-address case should use RISBLG.
78 define i32 @f9(i32 %a, i32 %b) {
80 ; CHECK: risblg %r2, %r3, 16, 158, 0
82 %and = and i32 %b, 65534
86 ; ANDs of 0xffff are zero extensions from i16.
87 define i32 @f10(i32 %a, i32 %b) {
89 ; CHECK: llhr %r2, %r3
91 %and = and i32 %b, 65535
95 ; Check the next value up, which must again use NILF.
96 define i32 @f11(i32 %a) {
98 ; CHECK: nilf %r2, 65536
100 %and = and i32 %a, 65536
104 ; ...but the three-address case can use RISBLG.
105 define i32 @f12(i32 %a, i32 %b) {
107 ; CHECK: risblg %r2, %r3, 15, 143, 0
109 %and = and i32 %b, 65536
113 ; Check the lowest useful NILH value.
114 define i32 @f13(i32 %a) {
118 %and = and i32 %a, 131071
122 ; ...but RISBLG is OK in the three-address case.
123 define i32 @f14(i32 %a, i32 %b) {
125 ; CHECK: risblg %r2, %r3, 15, 159, 0
127 %and = and i32 %b, 131071
131 ; Check the highest useful NILF value.
132 define i32 @f15(i32 %a) {
134 ; CHECK: nilf %r2, 4294901758
136 %and = and i32 %a, -65538
140 ; Check the next value up, which is the highest useful NILH value.
141 define i32 @f16(i32 %a) {
143 ; CHECK: nilh %r2, 65534
145 %and = and i32 %a, -65537
149 ; Check the next value up, which is the first useful NILL value.
150 define i32 @f17(i32 %a) {
154 %and = and i32 %a, -65536
158 ; ...although the three-address case should use RISBLG.
159 define i32 @f18(i32 %a, i32 %b) {
161 ; CHECK: risblg %r2, %r3, 0, 143, 0
163 %and = and i32 %b, -65536
167 ; Check the next value up again, which can still use NILL.
168 define i32 @f19(i32 %a) {
172 %and = and i32 %a, -65535
176 ; Check the next value up again, which cannot use RISBLG.
177 define i32 @f20(i32 %a, i32 %b) {
181 %and = and i32 %b, -65534
185 ; Check the last useful mask, which can use NILL.
186 define i32 @f21(i32 %a) {
188 ; CHECK: nill %r2, 65534
190 %and = and i32 %a, -2
194 ; ...or RISBLG for the three-address case.
195 define i32 @f22(i32 %a, i32 %b) {
197 ; CHECK: risblg %r2, %r3, 0, 158, 0
199 %and = and i32 %b, -2
203 ; Test that RISBLG can be used when inserting a non-wraparound mask
204 ; into another register.
205 define i64 @f23(i64 %a, i32 %b) {
207 ; CHECK: risblg %r2, %r3, 30, 158, 0
209 %and1 = and i64 %a, -4294967296
210 %and2 = and i32 %b, 2
211 %ext = zext i32 %and2 to i64
212 %or = or i64 %and1, %ext
216 ; ...and when inserting a wrap-around mask.
217 define i64 @f24(i64 %a, i32 %b) {
219 ; CHECK: risblg %r2, %r3, 30, 156
221 %and1 = and i64 %a, -4294967296
222 %and2 = and i32 %b, -5
223 %ext = zext i32 %and2 to i64
224 %or = or i64 %and1, %ext