1 ; Test the use of TEST UNDER MASK for 64-bit operations.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
8 ; Check the lowest useful TMLL value.
9 define void @f1(i64 %a) {
16 %cmp = icmp eq i64 %and, 0
17 br i1 %cmp, label %exit, label %store
27 ; Check the high end of the TMLL range.
28 define void @f2(i64 %a) {
30 ; CHECK: tmll %r2, 65535
34 %and = and i64 %a, 65535
35 %cmp = icmp ne i64 %and, 0
36 br i1 %cmp, label %exit, label %store
46 ; Check the lowest useful TMLH value, which is the next value up.
47 define void @f3(i64 %a) {
53 %and = and i64 %a, 65536
54 %cmp = icmp ne i64 %and, 0
55 br i1 %cmp, label %exit, label %store
65 ; Check the next value up again, which cannot use TM.
66 define void @f4(i64 %a) {
68 ; CHECK-NOT: {{tm[lh].}}
71 %and = and i64 %a, 4294901759
72 %cmp = icmp eq i64 %and, 0
73 br i1 %cmp, label %exit, label %store
83 ; Check the high end of the TMLH range.
84 define void @f5(i64 %a) {
86 ; CHECK: tmlh %r2, 65535
90 %and = and i64 %a, 4294901760
91 %cmp = icmp eq i64 %and, 0
92 br i1 %cmp, label %exit, label %store
102 ; Check the lowest useful TMHL value.
103 define void @f6(i64 %a) {
109 %and = and i64 %a, 4294967296
110 %cmp = icmp eq i64 %and, 0
111 br i1 %cmp, label %exit, label %store
121 ; Check the next value up again, which cannot use TM.
122 define void @f7(i64 %a) {
124 ; CHECK-NOT: {{tm[lh].}}
127 %and = and i64 %a, 4294967297
128 %cmp = icmp ne i64 %and, 0
129 br i1 %cmp, label %exit, label %store
139 ; Check the high end of the TMHL range.
140 define void @f8(i64 %a) {
142 ; CHECK: tmhl %r2, 65535
146 %and = and i64 %a, 281470681743360
147 %cmp = icmp ne i64 %and, 0
148 br i1 %cmp, label %exit, label %store
158 ; Check the lowest useful TMHH value.
159 define void @f9(i64 %a) {
165 %and = and i64 %a, 281474976710656
166 %cmp = icmp ne i64 %and, 0
167 br i1 %cmp, label %exit, label %store
177 ; Check the high end of the TMHH range.
178 define void @f10(i64 %a) {
180 ; CHECK: tmhh %r2, 65535
184 %and = and i64 %a, 18446462598732840960
185 %cmp = icmp eq i64 %and, 0
186 br i1 %cmp, label %exit, label %store
196 ; Check that we can fold an SHL into a TMxx mask.
197 define void @f11(i64 %a) {
199 ; CHECK: tmhl %r2, 32768
204 %and = and i64 %shl, 281474976710656
205 %cmp = icmp ne i64 %and, 0
206 br i1 %cmp, label %exit, label %store
216 ; Check that we can fold an SHR into a TMxx mask.
217 define void @f12(i64 %a) {
219 ; CHECK: tmhh %r2, 256
223 %shr = lshr i64 %a, 56
224 %and = and i64 %shr, 1
225 %cmp = icmp ne i64 %and, 0
226 br i1 %cmp, label %exit, label %store
236 ; Check a case where TMHH can be used to implement a ult comparison.
237 define void @f13(i64 %a) {
239 ; CHECK: tmhh %r2, 49152
243 %cmp = icmp ult i64 %a, 13835058055282163712
244 br i1 %cmp, label %exit, label %store
254 ; And again with ule.
255 define void @f14(i64 %a) {
257 ; CHECK: tmhh %r2, 49152
261 %cmp = icmp ule i64 %a, 13835058055282163711
262 br i1 %cmp, label %exit, label %store
272 ; And again with ugt.
273 define void @f15(i64 %a) {
275 ; CHECK: tmhh %r2, 49152
279 %cmp = icmp ugt i64 %a, 13835058055282163711
280 br i1 %cmp, label %exit, label %store
290 ; And again with uge.
291 define void @f16(i64 %a) {
293 ; CHECK: tmhh %r2, 49152
297 %cmp = icmp uge i64 %a, 13835058055282163712
298 br i1 %cmp, label %exit, label %store
308 ; Decrease the constant from f13 to make TMHH invalid.
309 define void @f17(i64 %a) {
312 ; CHECK: srlg [[REG:%r[0-5]]], %r2, 48
313 ; CHECK: cgfi [[REG]], 49151
317 %cmp = icmp ult i64 %a, 13834776580305453056
318 br i1 %cmp, label %exit, label %store
328 ; Check that we don't use TMHH just to test the top bit.
329 define void @f18(i64 %a) {
332 ; CHECK: cgibhe %r2, 0, 0(%r14)
335 %cmp = icmp ult i64 %a, 9223372036854775808
336 br i1 %cmp, label %exit, label %store
346 ; Check that we don't fold a shift if the comparison value
347 ; would need to be shifted out of range
348 define void @f19(i64 %a) {
351 ; CHECK: srlg [[REG:%r[0-5]]], %r2, 63
352 ; CHECK: cgibl [[REG]], 3, 0(%r14)
355 %shr = lshr i64 %a, 63
356 %cmp = icmp ult i64 %shr, 3
357 br i1 %cmp, label %exit, label %store