1 ; Test 32-bit arithmetic shifts right.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check the low end of the SRA range.
6 define i32 @f1(i32 %a) {
10 %shift = ashr i32 %a, 1
14 ; Check the high end of the defined SRA range.
15 define i32 @f2(i32 %a) {
19 %shift = ashr i32 %a, 31
23 ; We don't generate shifts by out-of-range values.
24 define i32 @f3(i32 %a) {
26 ; CHECK-NOT: sra %r2, 32
28 %shift = ashr i32 %a, 32
32 ; Make sure that we don't generate negative shift amounts.
33 define i32 @f4(i32 %a, i32 %amt) {
35 ; CHECK-NOT: sra %r2, -1{{.*}}
37 %sub = sub i32 %amt, 1
38 %shift = ashr i32 %a, %sub
42 ; Check variable shifts.
43 define i32 @f5(i32 %a, i32 %amt) {
45 ; CHECK: sra %r2, 0(%r3)
47 %shift = ashr i32 %a, %amt
51 ; Check shift amounts that have a constant term.
52 define i32 @f6(i32 %a, i32 %amt) {
54 ; CHECK: sra %r2, 10(%r3)
56 %add = add i32 %amt, 10
57 %shift = ashr i32 %a, %add
61 ; ...and again with a truncated 64-bit shift amount.
62 define i32 @f7(i32 %a, i64 %amt) {
64 ; CHECK: sra %r2, 10(%r3)
66 %add = add i64 %amt, 10
67 %trunc = trunc i64 %add to i32
68 %shift = ashr i32 %a, %trunc
72 ; Check shift amounts that have the largest in-range constant term. We could
73 ; mask the amount instead.
74 define i32 @f8(i32 %a, i32 %amt) {
76 ; CHECK: sra %r2, 4095(%r3)
78 %add = add i32 %amt, 4095
79 %shift = ashr i32 %a, %add
83 ; Check the next value up. Again, we could mask the amount instead.
84 define i32 @f9(i32 %a, i32 %amt) {
86 ; CHECK: ahi %r3, 4096
87 ; CHECK: sra %r2, 0(%r3)
89 %add = add i32 %amt, 4096
90 %shift = ashr i32 %a, %add
94 ; Check that we don't try to generate "indexed" shifts.
95 define i32 @f10(i32 %a, i32 %b, i32 %c) {
97 ; CHECK: ar {{%r3, %r4|%r4, %r3}}
98 ; CHECK: sra %r2, 0({{%r[34]}})
100 %add = add i32 %b, %c
101 %shift = ashr i32 %a, %add
105 ; Check that the shift amount uses an address register. It cannot be in %r0.
106 define i32 @f11(i32 %a, i32 *%ptr) {
108 ; CHECK: l %r1, 0(%r3)
109 ; CHECK: sra %r2, 0(%r1)
111 %amt = load i32, i32 *%ptr
112 %shift = ashr i32 %a, %amt