blob: 5dab36b379c4d8dd5c018c937cfd40a33513cc40 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 32-bit shifts left.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check the low end of the SLL range.
6define i32 @f1(i32 %a) {
Stephen Lind24ab202013-07-14 06:24:09 +00007; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00008; CHECK: sll %r2, 1
9; CHECK: br %r14
10 %shift = shl i32 %a, 1
11 ret i32 %shift
12}
13
14; Check the high end of the defined SLL range.
15define i32 @f2(i32 %a) {
Stephen Lind24ab202013-07-14 06:24:09 +000016; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000017; CHECK: sll %r2, 31
18; CHECK: br %r14
19 %shift = shl i32 %a, 31
20 ret i32 %shift
21}
22
23; We don't generate shifts by out-of-range values.
24define i32 @f3(i32 %a) {
Stephen Lind24ab202013-07-14 06:24:09 +000025; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000026; CHECK-NOT: sll %r2, 32
27; CHECK: br %r14
28 %shift = shl i32 %a, 32
29 ret i32 %shift
30}
31
32; Make sure that we don't generate negative shift amounts.
33define i32 @f4(i32 %a, i32 %amt) {
Stephen Lind24ab202013-07-14 06:24:09 +000034; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000035; CHECK-NOT: sll %r2, -1{{.*}}
36; CHECK: br %r14
37 %sub = sub i32 %amt, 1
38 %shift = shl i32 %a, %sub
39 ret i32 %shift
40}
41
42; Check variable shifts.
43define i32 @f5(i32 %a, i32 %amt) {
Stephen Lind24ab202013-07-14 06:24:09 +000044; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000045; CHECK: sll %r2, 0(%r3)
46; CHECK: br %r14
47 %shift = shl i32 %a, %amt
48 ret i32 %shift
49}
50
51; Check shift amounts that have a constant term.
52define i32 @f6(i32 %a, i32 %amt) {
Stephen Lind24ab202013-07-14 06:24:09 +000053; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000054; CHECK: sll %r2, 10(%r3)
55; CHECK: br %r14
56 %add = add i32 %amt, 10
57 %shift = shl i32 %a, %add
58 ret i32 %shift
59}
60
61; ...and again with a truncated 64-bit shift amount.
62define i32 @f7(i32 %a, i64 %amt) {
Stephen Lind24ab202013-07-14 06:24:09 +000063; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000064; CHECK: sll %r2, 10(%r3)
65; CHECK: br %r14
66 %add = add i64 %amt, 10
67 %trunc = trunc i64 %add to i32
68 %shift = shl i32 %a, %trunc
69 ret i32 %shift
70}
71
72; Check shift amounts that have the largest in-range constant term. We could
73; mask the amount instead.
74define i32 @f8(i32 %a, i32 %amt) {
Stephen Lind24ab202013-07-14 06:24:09 +000075; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000076; CHECK: sll %r2, 4095(%r3)
77; CHECK: br %r14
78 %add = add i32 %amt, 4095
79 %shift = shl i32 %a, %add
80 ret i32 %shift
81}
82
83; Check the next value up. Again, we could mask the amount instead.
84define i32 @f9(i32 %a, i32 %amt) {
Stephen Lind24ab202013-07-14 06:24:09 +000085; CHECK-LABEL: f9:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000086; CHECK: ahi %r3, 4096
87; CHECK: sll %r2, 0(%r3)
88; CHECK: br %r14
89 %add = add i32 %amt, 4096
90 %shift = shl i32 %a, %add
91 ret i32 %shift
92}
93
94; Check that we don't try to generate "indexed" shifts.
95define i32 @f10(i32 %a, i32 %b, i32 %c) {
Stephen Lind24ab202013-07-14 06:24:09 +000096; CHECK-LABEL: f10:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000097; CHECK: ar {{%r3, %r4|%r4, %r3}}
98; CHECK: sll %r2, 0({{%r[34]}})
99; CHECK: br %r14
100 %add = add i32 %b, %c
101 %shift = shl i32 %a, %add
102 ret i32 %shift
103}
104
105; Check that the shift amount uses an address register. It cannot be in %r0.
106define i32 @f11(i32 %a, i32 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000107; CHECK-LABEL: f11:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000108; CHECK: l %r1, 0(%r3)
109; CHECK: sll %r2, 0(%r1)
110; CHECK: br %r14
111 %amt = load i32 *%ptr
112 %shift = shl i32 %a, %amt
113 ret i32 %shift
114}