1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Test shortening of NILL to NILF when the result is used as a shift amount.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 ; Test logical shift right.
7 define i32 @f1(i32 %a, i32 %sh) {
10 ; CHECK-NEXT: nill %r3, 31
11 ; CHECK-NEXT: srl %r2, 0(%r3)
13 %and = and i32 %sh, 31
14 %shift = lshr i32 %a, %and
18 ; Test arithmetic shift right.
19 define i32 @f2(i32 %a, i32 %sh) {
22 ; CHECK-NEXT: nill %r3, 31
23 ; CHECK-NEXT: sra %r2, 0(%r3)
25 %and = and i32 %sh, 31
26 %shift = ashr i32 %a, %and
31 define i32 @f3(i32 %a, i32 %sh) {
34 ; CHECK-NEXT: nill %r3, 31
35 ; CHECK-NEXT: sll %r2, 0(%r3)
37 %and = and i32 %sh, 31
38 %shift = shl i32 %a, %and
42 ; Test 64-bit logical shift right.
43 define i64 @f4(i64 %a, i64 %sh) {
46 ; CHECK-NEXT: nill %r3, 31
47 ; CHECK-NEXT: srlg %r2, %r2, 0(%r3)
49 %and = and i64 %sh, 31
50 %shift = lshr i64 %a, %and
54 ; Test 64-bit arithmetic shift right.
55 define i64 @f5(i64 %a, i64 %sh) {
58 ; CHECK-NEXT: nill %r3, 31
59 ; CHECK-NEXT: srag %r2, %r2, 0(%r3)
61 %and = and i64 %sh, 31
62 %shift = ashr i64 %a, %and
66 ; Test 64-bit shift left.
67 define i64 @f6(i64 %a, i64 %sh) {
70 ; CHECK-NEXT: nill %r3, 31
71 ; CHECK-NEXT: sllg %r2, %r2, 0(%r3)
73 %and = and i64 %sh, 31
74 %shift = shl i64 %a, %and
78 ; Test shift with negative 32-bit value.
79 define i32 @f8(i32 %a, i32 %sh, i32 %test) {
82 ; CHECK-NEXT: nill %r3, 65529
83 ; CHECK-NEXT: sll %r2, 0(%r3)
85 %and = and i32 %sh, -7
86 %shift = shl i32 %a, %and
91 ; Test shift with negative 64-bit value.
92 define i64 @f9(i64 %a, i64 %sh, i64 %test) {
95 ; CHECK-NEXT: nill %r3, 65529
96 ; CHECK-NEXT: sllg %r2, %r2, 0(%r3)
98 %and = and i64 %sh, -7
99 %shift = shl i64 %a, %and