1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Test 32-bit shifts left.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 ; Check the low end of the SLL range.
7 define i32 @f1(i32 %a) {
10 ; CHECK-NEXT: sll %r2, 1
12 %shift = shl i32 %a, 1
16 ; Check the high end of the defined SLL range.
17 define i32 @f2(i32 %a) {
20 ; CHECK-NEXT: sll %r2, 31
22 %shift = shl i32 %a, 31
26 ; We don't generate shifts by out-of-range values.
27 define i32 @f3(i32 %a) {
31 %shift = shl i32 %a, 32
35 ; Make sure that we don't generate negative shift amounts.
36 define i32 @f4(i32 %a, i32 %amt) {
39 ; CHECK-NEXT: ahi %r3, -1
40 ; CHECK-NEXT: sll %r2, 0(%r3)
42 %sub = sub i32 %amt, 1
43 %shift = shl i32 %a, %sub
47 ; Check variable shifts.
48 define i32 @f5(i32 %a, i32 %amt) {
51 ; CHECK-NEXT: sll %r2, 0(%r3)
53 %shift = shl i32 %a, %amt
57 ; Check shift amounts that have a constant term.
58 define i32 @f6(i32 %a, i32 %amt) {
61 ; CHECK-NEXT: sll %r2, 10(%r3)
63 %add = add i32 %amt, 10
64 %shift = shl i32 %a, %add
68 ; ...and again with a truncated 64-bit shift amount.
69 define i32 @f7(i32 %a, i64 %amt) {
72 ; CHECK-NEXT: sll %r2, 10(%r3)
74 %add = add i64 %amt, 10
75 %trunc = trunc i64 %add to i32
76 %shift = shl i32 %a, %trunc
80 ; Check shift amounts that have the largest in-range constant term. We could
81 ; mask the amount instead.
82 define i32 @f8(i32 %a, i32 %amt) {
85 ; CHECK-NEXT: sll %r2, 4095(%r3)
87 %add = add i32 %amt, 4095
88 %shift = shl i32 %a, %add
92 ; Check the next value up. Again, we could mask the amount instead.
93 define i32 @f9(i32 %a, i32 %amt) {
96 ; CHECK-NEXT: ahi %r3, 4096
97 ; CHECK-NEXT: sll %r2, 0(%r3)
99 %add = add i32 %amt, 4096
100 %shift = shl i32 %a, %add
104 ; Check that we don't try to generate "indexed" shifts.
105 define i32 @f10(i32 %a, i32 %b, i32 %c) {
108 ; CHECK-NEXT: ar %r3, %r4
109 ; CHECK-NEXT: sll %r2, 0(%r3)
110 ; CHECK-NEXT: br %r14
111 %add = add i32 %b, %c
112 %shift = shl i32 %a, %add
116 ; Check that the shift amount uses an address register. It cannot be in %r0.
117 define i32 @f11(i32 %a, i32 *%ptr) {
120 ; CHECK-NEXT: l %r1, 0(%r3)
121 ; CHECK-NEXT: sll %r2, 0(%r1)
122 ; CHECK-NEXT: br %r14
123 %amt = load i32, i32 *%ptr
124 %shift = shl i32 %a, %amt