1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Test 32-bit logical shifts right.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 ; Check the low end of the SRLG range.
7 define i64 @f1(i64 %a) {
10 ; CHECK-NEXT: srlg %r2, %r2, 1
12 %shift = lshr i64 %a, 1
16 ; Check the high end of the defined SRLG range.
17 define i64 @f2(i64 %a) {
20 ; CHECK-NEXT: srlg %r2, %r2, 63
22 %shift = lshr i64 %a, 63
26 ; We don't generate shifts by out-of-range values.
27 define i64 @f3(i64 %a) {
31 %shift = lshr i64 %a, 64
35 ; Check variable shifts.
36 define i64 @f4(i64 %a, i64 %amt) {
39 ; CHECK-NEXT: srlg %r2, %r2, 0(%r3)
41 %shift = lshr i64 %a, %amt
45 ; Check shift amounts that have a constant term.
46 define i64 @f5(i64 %a, i64 %amt) {
49 ; CHECK-NEXT: srlg %r2, %r2, 10(%r3)
51 %add = add i64 %amt, 10
52 %shift = lshr i64 %a, %add
56 ; ...and again with a sign-extended 32-bit shift amount.
57 define i64 @f6(i64 %a, i32 %amt) {
60 ; CHECK-NEXT: srlg %r2, %r2, 10(%r3)
62 %add = add i32 %amt, 10
63 %addext = sext i32 %add to i64
64 %shift = lshr i64 %a, %addext
68 ; ...and now with a zero-extended 32-bit shift amount.
69 define i64 @f7(i64 %a, i32 %amt) {
72 ; CHECK-NEXT: srlg %r2, %r2, 10(%r3)
74 %add = add i32 %amt, 10
75 %addext = zext i32 %add to i64
76 %shift = lshr i64 %a, %addext
80 ; Check shift amounts that have the largest in-range constant term. We could
81 ; mask the amount instead.
82 define i64 @f8(i64 %a, i64 %amt) {
85 ; CHECK-NEXT: srlg %r2, %r2, 524287(%r3)
87 %add = add i64 %amt, 524287
88 %shift = lshr i64 %a, %add
92 ; Check the next value up, which without masking must use a separate
94 define i64 @f9(i64 %a, i64 %amt) {
97 ; CHECK-NEXT: afi %r3, 524288
98 ; CHECK-NEXT: srlg %r2, %r2, 0(%r3)
100 %add = add i64 %amt, 524288
101 %shift = lshr i64 %a, %add
105 ; Check cases where 1 is subtracted from the shift amount.
106 define i64 @f10(i64 %a, i64 %amt) {
109 ; CHECK-NEXT: srlg %r2, %r2, -1(%r3)
110 ; CHECK-NEXT: br %r14
111 %sub = sub i64 %amt, 1
112 %shift = lshr i64 %a, %sub
116 ; Check the lowest value that can be subtracted from the shift amount.
117 ; Again, we could mask the shift amount instead.
118 define i64 @f11(i64 %a, i64 %amt) {
121 ; CHECK-NEXT: srlg %r2, %r2, -524288(%r3)
122 ; CHECK-NEXT: br %r14
123 %sub = sub i64 %amt, 524288
124 %shift = lshr i64 %a, %sub
128 ; Check the next value down, which without masking must use a separate
130 define i64 @f12(i64 %a, i64 %amt) {
133 ; CHECK-NEXT: afi %r3, -524289
134 ; CHECK-NEXT: srlg %r2, %r2, 0(%r3)
135 ; CHECK-NEXT: br %r14
136 %sub = sub i64 %amt, 524289
137 %shift = lshr i64 %a, %sub
141 ; Check that we don't try to generate "indexed" shifts.
142 define i64 @f13(i64 %a, i64 %b, i64 %c) {
145 ; CHECK-NEXT: agr %r3, %r4
146 ; CHECK-NEXT: srlg %r2, %r2, 0(%r3)
147 ; CHECK-NEXT: br %r14
148 %add = add i64 %b, %c
149 %shift = lshr i64 %a, %add
153 ; Check that the shift amount uses an address register. It cannot be in %r0.
154 define i64 @f14(i64 %a, ptr %ptr) {
157 ; CHECK-NEXT: l %r1, 4(%r3)
158 ; CHECK-NEXT: srlg %r2, %r2, 0(%r1)
159 ; CHECK-NEXT: br %r14
160 %amt = load i64, ptr %ptr
161 %shift = lshr i64 %a, %amt