1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4 declare i8 @llvm.fshr.i8(i8, i8, i8)
5 declare i16 @llvm.fshr.i16(i16, i16, i16)
6 declare i32 @llvm.fshr.i32(i32, i32, i32)
7 declare i64 @llvm.fshr.i64(i64, i64, i64)
8 declare i128 @llvm.fshr.i128(i128, i128, i128)
11 ; Variable Funnel Shift
14 define i8 @var_shift_i8(i8 %x, i8 %y, i8 %z) {
15 ; CHECK-LABEL: var_shift_i8:
17 ; CHECK-NEXT: # kill: def $r3l killed $r3l def $r3d
18 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
19 ; CHECK-NEXT: sll %r2, 8
20 ; CHECK-NEXT: rosbg %r2, %r3, 56, 63, 0
21 ; CHECK-NEXT: nill %r4, 7
22 ; CHECK-NEXT: srl %r2, 0(%r4)
23 ; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
25 %tmp = tail call i8 @llvm.fshr.i8(i8 %x, i8 %y, i8 %z)
29 define i16 @var_shift_i16(i16 %x, i16 %y, i16 %z) {
30 ; CHECK-LABEL: var_shift_i16:
32 ; CHECK-NEXT: # kill: def $r3l killed $r3l def $r3d
33 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
34 ; CHECK-NEXT: sll %r2, 16
35 ; CHECK-NEXT: rosbg %r2, %r3, 48, 63, 0
36 ; CHECK-NEXT: nill %r4, 15
37 ; CHECK-NEXT: srl %r2, 0(%r4)
38 ; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
40 %tmp = tail call i16 @llvm.fshr.i16(i16 %x, i16 %y, i16 %z)
44 define i32 @var_shift_i32(i32 %x, i32 %y, i32 %z) {
45 ; CHECK-LABEL: var_shift_i32:
47 ; CHECK-NEXT: lr %r1, %r4
48 ; CHECK-NEXT: nill %r1, 31
49 ; CHECK-NEXT: srl %r3, 0(%r1)
50 ; CHECK-NEXT: sll %r2, 1
51 ; CHECK-NEXT: xilf %r4, 4294967295
52 ; CHECK-NEXT: nill %r4, 31
53 ; CHECK-NEXT: sll %r2, 0(%r4)
54 ; CHECK-NEXT: or %r2, %r3
56 %tmp = tail call i32 @llvm.fshr.i32(i32 %x, i32 %y, i32 %z)
60 define i64 @var_shift_i64(i64 %x, i64 %y, i64 %z) {
61 ; CHECK-LABEL: var_shift_i64:
63 ; CHECK-NEXT: srlg %r0, %r3, 0(%r4)
64 ; CHECK-NEXT: sllg %r1, %r2, 1
65 ; CHECK-NEXT: xilf %r4, 4294967295
66 ; CHECK-NEXT: sllg %r2, %r1, 0(%r4)
67 ; CHECK-NEXT: ogr %r2, %r0
69 %tmp = tail call i64 @llvm.fshr.i64(i64 %x, i64 %y, i64 %z)
73 define i128 @var_shift_i128(i128 %x, i128 %y, i128 %z) {
74 ; CHECK-LABEL: var_shift_i128:
76 ; CHECK-NEXT: stmg %r14, %r15, 112(%r15)
77 ; CHECK-NEXT: .cfi_offset %r14, -48
78 ; CHECK-NEXT: .cfi_offset %r15, -40
79 ; CHECK-NEXT: lg %r1, 8(%r5)
80 ; CHECK-NEXT: lg %r5, 8(%r3)
81 ; CHECK-NEXT: lg %r0, 0(%r4)
82 ; CHECK-NEXT: tmll %r1, 64
83 ; CHECK-NEXT: jne .LBB4_2
84 ; CHECK-NEXT: # %bb.1:
85 ; CHECK-NEXT: lg %r4, 8(%r4)
86 ; CHECK-NEXT: srlg %r14, %r0, 0(%r1)
87 ; CHECK-NEXT: jne .LBB4_3
88 ; CHECK-NEXT: j .LBB4_4
89 ; CHECK-NEXT: .LBB4_2:
90 ; CHECK-NEXT: lgr %r4, %r0
91 ; CHECK-NEXT: lgr %r0, %r5
92 ; CHECK-NEXT: srlg %r14, %r0, 0(%r1)
93 ; CHECK-NEXT: je .LBB4_4
94 ; CHECK-NEXT: .LBB4_3:
95 ; CHECK-NEXT: lg %r5, 0(%r3)
96 ; CHECK-NEXT: .LBB4_4:
97 ; CHECK-NEXT: sllg %r3, %r5, 1
98 ; CHECK-NEXT: srlg %r4, %r4, 0(%r1)
99 ; CHECK-NEXT: xilf %r1, 4294967295
100 ; CHECK-NEXT: sllg %r3, %r3, 0(%r1)
101 ; CHECK-NEXT: ogr %r3, %r14
102 ; CHECK-NEXT: sllg %r0, %r0, 1
103 ; CHECK-NEXT: sllg %r0, %r0, 0(%r1)
104 ; CHECK-NEXT: ogr %r0, %r4
105 ; CHECK-NEXT: stg %r0, 8(%r2)
106 ; CHECK-NEXT: stg %r3, 0(%r2)
107 ; CHECK-NEXT: lmg %r14, %r15, 112(%r15)
108 ; CHECK-NEXT: br %r14
109 %tmp = tail call i128 @llvm.fshr.i128(i128 %x, i128 %y, i128 %z)
117 define i8 @const_shift_i8(i8 %x, i8 %y) {
118 ; CHECK-LABEL: const_shift_i8:
120 ; CHECK-NEXT: # kill: def $r3l killed $r3l def $r3d
121 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
122 ; CHECK-NEXT: sll %r2, 1
123 ; CHECK-NEXT: rosbg %r2, %r3, 63, 63, 57
124 ; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
125 ; CHECK-NEXT: br %r14
126 %tmp = tail call i8 @llvm.fshr.i8(i8 %x, i8 %y, i8 7)
130 define i16 @const_shift_i16(i16 %x, i16 %y) {
131 ; CHECK-LABEL: const_shift_i16:
133 ; CHECK-NEXT: # kill: def $r3l killed $r3l def $r3d
134 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
135 ; CHECK-NEXT: sll %r2, 9
136 ; CHECK-NEXT: rosbg %r2, %r3, 55, 63, 57
137 ; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
138 ; CHECK-NEXT: br %r14
139 %tmp = tail call i16 @llvm.fshr.i16(i16 %x, i16 %y, i16 7)
143 define i32 @const_shift_i32(i32 %x, i32 %y) {
144 ; CHECK-LABEL: const_shift_i32:
146 ; CHECK-NEXT: # kill: def $r3l killed $r3l def $r3d
147 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
148 ; CHECK-NEXT: sll %r2, 25
149 ; CHECK-NEXT: rosbg %r2, %r3, 39, 63, 57
150 ; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
151 ; CHECK-NEXT: br %r14
152 %tmp = tail call i32 @llvm.fshr.i32(i32 %x, i32 %y, i32 7)
156 define i64 @const_shift_i64(i64 %x, i64 %y) {
157 ; CHECK-LABEL: const_shift_i64:
159 ; CHECK-NEXT: sllg %r2, %r2, 57
160 ; CHECK-NEXT: rosbg %r2, %r3, 7, 63, 57
161 ; CHECK-NEXT: br %r14
162 %tmp = tail call i64 @llvm.fshr.i64(i64 %x, i64 %y, i64 7)