1 ; Test the use of TEST UNDER MASK for 32-bit operations.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
7 ; Check the lowest useful TMLL value.
8 define void @f1(i32 %a) {
15 %cmp = icmp eq i32 %and, 0
16 br i1 %cmp, label %exit, label %store
26 ; Check the high end of the TMLL range.
27 define void @f2(i32 %a) {
29 ; CHECK: tmll %r2, 65535
33 %and = and i32 %a, 65535
34 %cmp = icmp ne i32 %and, 0
35 br i1 %cmp, label %exit, label %store
45 ; Check the lowest useful TMLH value, which is the next value up.
46 define void @f3(i32 %a) {
52 %and = and i32 %a, 65536
53 %cmp = icmp ne i32 %and, 0
54 br i1 %cmp, label %exit, label %store
64 ; Check the next value up again, which cannot use TM.
65 define void @f4(i32 %a) {
67 ; CHECK-NOT: {{tm[lh].}}
70 %and = and i32 %a, 4294901759
71 %cmp = icmp eq i32 %and, 0
72 br i1 %cmp, label %exit, label %store
82 ; Check the high end of the TMLH range.
83 define void @f5(i32 %a) {
85 ; CHECK: tmlh %r2, 65535
89 %and = and i32 %a, 4294901760
90 %cmp = icmp eq i32 %and, 0
91 br i1 %cmp, label %exit, label %store
101 ; Check that we can use TMLL for LT comparisons that are equivalent to
102 ; an equality comparison with zero.
103 define void @f6(i32 %a) {
105 ; CHECK: tmll %r2, 240
109 %and = and i32 %a, 240
110 %cmp = icmp slt i32 %and, 16
111 br i1 %cmp, label %exit, label %store
121 ; ...same again with LE.
122 define void @f7(i32 %a) {
124 ; CHECK: tmll %r2, 240
128 %and = and i32 %a, 240
129 %cmp = icmp sle i32 %and, 15
130 br i1 %cmp, label %exit, label %store
140 ; Check that we can use TMLL for GE comparisons that are equivalent to
141 ; an inequality comparison with zero.
142 define void @f8(i32 %a) {
144 ; CHECK: tmll %r2, 240
148 %and = and i32 %a, 240
149 %cmp = icmp uge i32 %and, 16
150 br i1 %cmp, label %exit, label %store
160 ; ...same again with GT.
161 define void @f9(i32 %a) {
163 ; CHECK: tmll %r2, 240
167 %and = and i32 %a, 240
168 %cmp = icmp ugt i32 %and, 15
169 br i1 %cmp, label %exit, label %store
179 ; Check that we can use TMLL for LT comparisons that effectively
180 ; test whether the top bit is clear.
181 define void @f10(i32 %a) {
183 ; CHECK: tmll %r2, 35
187 %and = and i32 %a, 35
188 %cmp = icmp ult i32 %and, 8
189 br i1 %cmp, label %exit, label %store
199 ; ...same again with LE.
200 define void @f11(i32 %a) {
202 ; CHECK: tmll %r2, 35
206 %and = and i32 %a, 35
207 %cmp = icmp ule i32 %and, 31
208 br i1 %cmp, label %exit, label %store
218 ; Check that we can use TMLL for GE comparisons that effectively test
219 ; whether the top bit is set.
220 define void @f12(i32 %a) {
222 ; CHECK: tmll %r2, 140
226 %and = and i32 %a, 140
227 %cmp = icmp uge i32 %and, 128
228 br i1 %cmp, label %exit, label %store
238 ; ...same again for GT.
239 define void @f13(i32 %a) {
241 ; CHECK: tmll %r2, 140
245 %and = and i32 %a, 140
246 %cmp = icmp ugt i32 %and, 126
247 br i1 %cmp, label %exit, label %store
257 ; Check that we can use TMLL for equality comparisons with the mask.
258 define void @f14(i32 %a) {
260 ; CHECK: tmll %r2, 101
264 %and = and i32 %a, 101
265 %cmp = icmp eq i32 %and, 101
266 br i1 %cmp, label %exit, label %store
276 ; Check that we can use TMLL for inequality comparisons with the mask.
277 define void @f15(i32 %a) {
279 ; CHECK: tmll %r2, 65519
283 %and = and i32 %a, 65519
284 %cmp = icmp ne i32 %and, 65519
285 br i1 %cmp, label %exit, label %store
295 ; Check that we can use TMLL for LT comparisons that are equivalent
296 ; to inequality comparisons with the mask.
297 define void @f16(i32 %a) {
299 ; CHECK: tmll %r2, 130
303 %and = and i32 %a, 130
304 %cmp = icmp ult i32 %and, 129
305 br i1 %cmp, label %exit, label %store
315 ; ...same again with LE.
316 define void @f17(i32 %a) {
318 ; CHECK: tmll %r2, 130
322 %and = and i32 %a, 130
323 %cmp = icmp ule i32 %and, 128
324 br i1 %cmp, label %exit, label %store
334 ; Check that we can use TMLL for GE comparisons that are equivalent
335 ; to equality comparisons with the mask.
336 define void @f18(i32 %a) {
338 ; CHECK: tmll %r2, 194
342 %and = and i32 %a, 194
343 %cmp = icmp uge i32 %and, 193
344 br i1 %cmp, label %exit, label %store
354 ; ...same again for GT.
355 define void @f19(i32 %a) {
357 ; CHECK: tmll %r2, 194
361 %and = and i32 %a, 194
362 %cmp = icmp ugt i32 %and, 192
363 br i1 %cmp, label %exit, label %store
373 ; Check that we can use TMLL for equality comparisons for the low bit
374 ; when the mask has two bits.
375 define void @f20(i32 %a) {
377 ; CHECK: tmll %r2, 20
381 %and = and i32 %a, 20
382 %cmp = icmp eq i32 %and, 4
383 br i1 %cmp, label %exit, label %store
393 ; Check that we can use TMLL for inequality comparisons for the low bit
394 ; when the mask has two bits.
395 define void @f21(i32 %a) {
397 ; CHECK: tmll %r2, 20
401 %and = and i32 %a, 20
402 %cmp = icmp ne i32 %and, 4
403 br i1 %cmp, label %exit, label %store
413 ; Check that we can use TMLL for equality comparisons for the high bit
414 ; when the mask has two bits.
415 define void @f22(i32 %a) {
417 ; CHECK: tmll %r2, 20
421 %and = and i32 %a, 20
422 %cmp = icmp eq i32 %and, 16
423 br i1 %cmp, label %exit, label %store
433 ; Check that we can use TMLL for inequality comparisons for the high bit
434 ; when the mask has two bits.
435 define void @f23(i32 %a) {
437 ; CHECK: tmll %r2, 20
441 %and = and i32 %a, 20
442 %cmp = icmp ne i32 %and, 16
443 br i1 %cmp, label %exit, label %store
453 ; Check that we can fold an SHL into a TMxx mask.
454 define void @f24(i32 %a) {
456 ; CHECK: tmll %r2, 255
460 %shl = shl i32 %a, 12
461 %and = and i32 %shl, 1044480
462 %cmp = icmp ne i32 %and, 0
463 br i1 %cmp, label %exit, label %store
473 ; Check that we can fold an SHR into a TMxx mask.
474 define void @f25(i32 %a) {
476 ; CHECK: tmlh %r2, 512
480 %shr = lshr i32 %a, 25
481 %and = and i32 %shr, 1
482 %cmp = icmp ne i32 %and, 0
483 br i1 %cmp, label %exit, label %store