1 ; Test that the case of (64 - shift) used by a shift/rotate instruction is
2 ; implemented with an lcr. This should also work for any multiple of 64.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
6 define i64 @f1(i64 %in, i64 %sh) {
9 ; CHECK: sllg %r2, %r2, 0(%r1)
10 %sub = sub i64 64, %sh
11 %shl = shl i64 %in, %sub
15 define i64 @f2(i64 %in, i64 %sh) {
18 ; CHECK: srag %r2, %r2, 0(%r1)
19 %sub = sub i64 64, %sh
20 %shl = ashr i64 %in, %sub
24 define i64 @f3(i64 %in, i64 %sh) {
27 ; CHECK: srlg %r2, %r2, 0(%r1)
28 %sub = sub i64 64, %sh
29 %shl = lshr i64 %in, %sub
33 define i64 @f4(i64 %in, i64 %sh) {
36 ; CHECK: rllg %r2, %r2, 0(%r1)
37 %shr = lshr i64 %in, %sh
38 %sub = sub i64 64, %sh
39 %shl = shl i64 %in, %sub
40 %or = or i64 %shl, %shr
44 define i64 @f5(i64 %in, i64 %sh) {
47 ; CHECK: sllg %r2, %r2, 0(%r1)
48 %sub = sub i64 128, %sh
49 %shl = shl i64 %in, %sub
53 define i64 @f6(i64 %in, i64 %sh) {
56 ; CHECK: srag %r2, %r2, 0(%r1)
57 %sub = sub i64 256, %sh
58 %shl = ashr i64 %in, %sub
62 define i64 @f7(i64 %in, i64 %sh) {
65 ; CHECK: srlg %r2, %r2, 0(%r1)
66 %sub = sub i64 512, %sh
67 %shl = lshr i64 %in, %sub
71 define i64 @f8(i64 %in, i64 %sh) {
74 ; CHECK: srlg %r0, %r2, 0(%r3)
75 ; CHECK: sllg %r2, %r2, 0(%r1)
77 %shr = lshr i64 %in, %sh
78 %sub = sub i64 1024, %sh
79 %shl = shl i64 %in, %sub
80 %or = or i64 %shl, %shr