1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; Test vector extraction of byte-swapped value to memory.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z15 | FileCheck %s
6 declare i16 @llvm.bswap.i16(i16)
7 declare i32 @llvm.bswap.i32(i32)
8 declare i64 @llvm.bswap.i64(i64)
9 declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
10 declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
11 declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
13 ; Test v8i16 extraction from the first element.
14 define void @f1(<8 x i16> %val, ptr %ptr) {
17 ; CHECK-NEXT: vstebrh %v24, 0(%r2), 0
19 %element = extractelement <8 x i16> %val, i32 0
20 %swap = call i16 @llvm.bswap.i16(i16 %element)
21 store i16 %swap, ptr %ptr
25 ; Test v8i16 extraction from the last element.
26 define void @f2(<8 x i16> %val, ptr %ptr) {
29 ; CHECK-NEXT: vstebrh %v24, 0(%r2), 7
31 %element = extractelement <8 x i16> %val, i32 7
32 %swap = call i16 @llvm.bswap.i16(i16 %element)
33 store i16 %swap, ptr %ptr
37 ; Test v8i16 extraction of an invalid element. This must compile,
38 ; but we don't care what it does.
39 define void @f3(<8 x i16> %val, ptr %ptr) {
43 %element = extractelement <8 x i16> %val, i32 8
44 %swap = call i16 @llvm.bswap.i16(i16 %element)
45 store i16 %swap, ptr %ptr
49 ; Test v8i16 extraction with the highest in-range offset.
50 define void @f4(<8 x i16> %val, ptr %base) {
53 ; CHECK-NEXT: vstebrh %v24, 4094(%r2), 5
55 %ptr = getelementptr i16, ptr %base, i32 2047
56 %element = extractelement <8 x i16> %val, i32 5
57 %swap = call i16 @llvm.bswap.i16(i16 %element)
58 store i16 %swap, ptr %ptr
62 ; Test v8i16 extraction with the first ouf-of-range offset.
63 define void @f5(<8 x i16> %val, ptr %base) {
66 ; CHECK-NEXT: aghi %r2, 4096
67 ; CHECK-NEXT: vstebrh %v24, 0(%r2), 1
69 %ptr = getelementptr i16, ptr %base, i32 2048
70 %element = extractelement <8 x i16> %val, i32 1
71 %swap = call i16 @llvm.bswap.i16(i16 %element)
72 store i16 %swap, ptr %ptr
76 ; Test v8i16 extraction from a variable element.
77 define void @f6(<8 x i16> %val, ptr %ptr, i32 %index) {
80 ; CHECK-NEXT: vlgvh %r0, %v24, 0(%r3)
81 ; CHECK-NEXT: strvh %r0, 0(%r2)
83 %element = extractelement <8 x i16> %val, i32 %index
84 %swap = call i16 @llvm.bswap.i16(i16 %element)
85 store i16 %swap, ptr %ptr
89 ; Test v8i16 extraction using a vector bswap.
90 define void @f7(<8 x i16> %val, ptr %ptr) {
93 ; CHECK-NEXT: vstebrh %v24, 0(%r2), 0
95 %swap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %val)
96 %element = extractelement <8 x i16> %swap, i32 0
97 store i16 %element, ptr %ptr
101 ; Test v4i32 extraction from the first element.
102 define void @f8(<4 x i32> %val, ptr %ptr) {
105 ; CHECK-NEXT: vstebrf %v24, 0(%r2), 0
106 ; CHECK-NEXT: br %r14
107 %element = extractelement <4 x i32> %val, i32 0
108 %swap = call i32 @llvm.bswap.i32(i32 %element)
109 store i32 %swap, ptr %ptr
113 ; Test v4i32 extraction from the last element.
114 define void @f9(<4 x i32> %val, ptr %ptr) {
117 ; CHECK-NEXT: vstebrf %v24, 0(%r2), 3
118 ; CHECK-NEXT: br %r14
119 %element = extractelement <4 x i32> %val, i32 3
120 %swap = call i32 @llvm.bswap.i32(i32 %element)
121 store i32 %swap, ptr %ptr
125 ; Test v4i32 extraction of an invalid element. This must compile,
126 ; but we don't care what it does.
127 define void @f10(<4 x i32> %val, ptr %ptr) {
130 ; CHECK-NEXT: br %r14
131 %element = extractelement <4 x i32> %val, i32 4
132 %swap = call i32 @llvm.bswap.i32(i32 %element)
133 store i32 %swap, ptr %ptr
137 ; Test v4i32 extraction with the highest in-range offset.
138 define void @f11(<4 x i32> %val, ptr %base) {
141 ; CHECK-NEXT: vstebrf %v24, 4092(%r2), 2
142 ; CHECK-NEXT: br %r14
143 %ptr = getelementptr i32, ptr %base, i32 1023
144 %element = extractelement <4 x i32> %val, i32 2
145 %swap = call i32 @llvm.bswap.i32(i32 %element)
146 store i32 %swap, ptr %ptr
150 ; Test v4i32 extraction with the first ouf-of-range offset.
151 define void @f12(<4 x i32> %val, ptr %base) {
154 ; CHECK-NEXT: aghi %r2, 4096
155 ; CHECK-NEXT: vstebrf %v24, 0(%r2), 1
156 ; CHECK-NEXT: br %r14
157 %ptr = getelementptr i32, ptr %base, i32 1024
158 %element = extractelement <4 x i32> %val, i32 1
159 %swap = call i32 @llvm.bswap.i32(i32 %element)
160 store i32 %swap, ptr %ptr
164 ; Test v4i32 extraction from a variable element.
165 define void @f13(<4 x i32> %val, ptr %ptr, i32 %index) {
168 ; CHECK-NEXT: vlgvf %r0, %v24, 0(%r3)
169 ; CHECK-NEXT: strv %r0, 0(%r2)
170 ; CHECK-NEXT: br %r14
171 %element = extractelement <4 x i32> %val, i32 %index
172 %swap = call i32 @llvm.bswap.i32(i32 %element)
173 store i32 %swap, ptr %ptr
177 ; Test v4i32 extraction using a vector bswap.
178 define void @f14(<4 x i32> %val, ptr %ptr) {
181 ; CHECK-NEXT: vstebrf %v24, 0(%r2), 0
182 ; CHECK-NEXT: br %r14
183 %swap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %val)
184 %element = extractelement <4 x i32> %swap, i32 0
185 store i32 %element, ptr %ptr
189 ; Test v2i64 extraction from the first element.
190 define void @f15(<2 x i64> %val, ptr %ptr) {
193 ; CHECK-NEXT: vstebrg %v24, 0(%r2), 0
194 ; CHECK-NEXT: br %r14
195 %element = extractelement <2 x i64> %val, i32 0
196 %swap = call i64 @llvm.bswap.i64(i64 %element)
197 store i64 %swap, ptr %ptr
201 ; Test v2i64 extraction from the last element.
202 define void @f16(<2 x i64> %val, ptr %ptr) {
205 ; CHECK-NEXT: vstebrg %v24, 0(%r2), 1
206 ; CHECK-NEXT: br %r14
207 %element = extractelement <2 x i64> %val, i32 1
208 %swap = call i64 @llvm.bswap.i64(i64 %element)
209 store i64 %swap, ptr %ptr
213 ; Test v2i64 extraction of an invalid element. This must compile,
214 ; but we don't care what it does.
215 define void @f17(<2 x i64> %val, ptr %ptr) {
218 ; CHECK-NEXT: br %r14
219 %element = extractelement <2 x i64> %val, i32 2
220 %swap = call i64 @llvm.bswap.i64(i64 %element)
221 store i64 %swap, ptr %ptr
225 ; Test v2i64 extraction with the highest in-range offset.
226 define void @f18(<2 x i64> %val, ptr %base) {
229 ; CHECK-NEXT: vstebrg %v24, 4088(%r2), 1
230 ; CHECK-NEXT: br %r14
231 %ptr = getelementptr i64, ptr %base, i32 511
232 %element = extractelement <2 x i64> %val, i32 1
233 %swap = call i64 @llvm.bswap.i64(i64 %element)
234 store i64 %swap, ptr %ptr
238 ; Test v2i64 extraction with the first ouf-of-range offset.
239 define void @f19(<2 x i64> %val, ptr %base) {
242 ; CHECK-NEXT: aghi %r2, 4096
243 ; CHECK-NEXT: vstebrg %v24, 0(%r2), 0
244 ; CHECK-NEXT: br %r14
245 %ptr = getelementptr i64, ptr %base, i32 512
246 %element = extractelement <2 x i64> %val, i32 0
247 %swap = call i64 @llvm.bswap.i64(i64 %element)
248 store i64 %swap, ptr %ptr
252 ; Test v2i64 extraction from a variable element.
253 define void @f20(<2 x i64> %val, ptr %ptr, i32 %index) {
256 ; CHECK-NEXT: vlgvg %r0, %v24, 0(%r3)
257 ; CHECK-NEXT: strvg %r0, 0(%r2)
258 ; CHECK-NEXT: br %r14
259 %element = extractelement <2 x i64> %val, i32 %index
260 %swap = call i64 @llvm.bswap.i64(i64 %element)
261 store i64 %swap, ptr %ptr
265 ; Test v2i64 extraction using a vector bswap.
266 define void @f21(<2 x i64> %val, ptr %ptr) {
269 ; CHECK-NEXT: vstebrg %v24, 0(%r2), 0
270 ; CHECK-NEXT: br %r14
271 %swap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %val)
272 %element = extractelement <2 x i64> %swap, i32 0
273 store i64 %element, ptr %ptr