1 ; Test vector extraction.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
5 ; Test v16i8 extraction of the first element.
6 define i8 @f1(<16 x i8> %val) {
8 ; CHECK: vlgvb %r2, %v24, 0
10 %ret = extractelement <16 x i8> %val, i32 0
14 ; Test v16i8 extraction of the last element.
15 define i8 @f2(<16 x i8> %val) {
17 ; CHECK: vlgvb %r2, %v24, 15
19 %ret = extractelement <16 x i8> %val, i32 15
23 ; Test v16i8 extractions of an absurd element number. This must compile
24 ; but we don't care what it does.
25 define i8 @f3(<16 x i8> %val) {
27 ; CHECK-NOT: vlgvb %r2, %v24, 100000
29 %ret = extractelement <16 x i8> %val, i32 100000
33 ; Test v16i8 extraction of a variable element.
34 define i8 @f4(<16 x i8> %val, i32 %index) {
36 ; CHECK: vlgvb %r2, %v24, 0(%r2)
38 %ret = extractelement <16 x i8> %val, i32 %index
42 ; Test v8i16 extraction of the first element.
43 define i16 @f5(<8 x i16> %val) {
45 ; CHECK: vlgvh %r2, %v24, 0
47 %ret = extractelement <8 x i16> %val, i32 0
51 ; Test v8i16 extraction of the last element.
52 define i16 @f6(<8 x i16> %val) {
54 ; CHECK: vlgvh %r2, %v24, 7
56 %ret = extractelement <8 x i16> %val, i32 7
60 ; Test v8i16 extractions of an absurd element number. This must compile
61 ; but we don't care what it does.
62 define i16 @f7(<8 x i16> %val) {
64 ; CHECK-NOT: vlgvh %r2, %v24, 100000
66 %ret = extractelement <8 x i16> %val, i32 100000
70 ; Test v8i16 extraction of a variable element.
71 define i16 @f8(<8 x i16> %val, i32 %index) {
73 ; CHECK: vlgvh %r2, %v24, 0(%r2)
75 %ret = extractelement <8 x i16> %val, i32 %index
79 ; Test v4i32 extraction of the first element.
80 define i32 @f9(<4 x i32> %val) {
82 ; CHECK: vlgvf %r2, %v24, 0
84 %ret = extractelement <4 x i32> %val, i32 0
88 ; Test v4i32 extraction of the last element.
89 define i32 @f10(<4 x i32> %val) {
91 ; CHECK: vlgvf %r2, %v24, 3
93 %ret = extractelement <4 x i32> %val, i32 3
97 ; Test v4i32 extractions of an absurd element number. This must compile
98 ; but we don't care what it does.
99 define i32 @f11(<4 x i32> %val) {
101 ; CHECK-NOT: vlgvf %r2, %v24, 100000
103 %ret = extractelement <4 x i32> %val, i32 100000
107 ; Test v4i32 extraction of a variable element.
108 define i32 @f12(<4 x i32> %val, i32 %index) {
110 ; CHECK: vlgvf %r2, %v24, 0(%r2)
112 %ret = extractelement <4 x i32> %val, i32 %index
116 ; Test v2i64 extraction of the first element.
117 define i64 @f13(<2 x i64> %val) {
119 ; CHECK: vlgvg %r2, %v24, 0
121 %ret = extractelement <2 x i64> %val, i32 0
125 ; Test v2i64 extraction of the last element.
126 define i64 @f14(<2 x i64> %val) {
128 ; CHECK: vlgvg %r2, %v24, 1
130 %ret = extractelement <2 x i64> %val, i32 1
134 ; Test v2i64 extractions of an absurd element number. This must compile
135 ; but we don't care what it does.
136 define i64 @f15(<2 x i64> %val) {
138 ; CHECK-NOT: vlgvg %r2, %v24, 100000
140 %ret = extractelement <2 x i64> %val, i32 100000
144 ; Test v2i64 extraction of a variable element.
145 define i64 @f16(<2 x i64> %val, i32 %index) {
147 ; CHECK: vlgvg %r2, %v24, 0(%r2)
149 %ret = extractelement <2 x i64> %val, i32 %index
153 ; Test v4f32 extraction of element 0.
154 define float @f17(<4 x float> %val) {
156 ; CHECK: vlr %v0, %v24
158 %ret = extractelement <4 x float> %val, i32 0
162 ; Test v4f32 extraction of element 1.
163 define float @f18(<4 x float> %val) {
165 ; CHECK: vrepf %v0, %v24, 1
167 %ret = extractelement <4 x float> %val, i32 1
171 ; Test v4f32 extraction of element 2.
172 define float @f19(<4 x float> %val) {
174 ; CHECK: vrepf %v0, %v24, 2
176 %ret = extractelement <4 x float> %val, i32 2
180 ; Test v4f32 extraction of element 3.
181 define float @f20(<4 x float> %val) {
183 ; CHECK: vrepf %v0, %v24, 3
185 %ret = extractelement <4 x float> %val, i32 3
189 ; Test v4f32 extractions of an absurd element number. This must compile
190 ; but we don't care what it does.
191 define float @f21(<4 x float> %val) {
192 %ret = extractelement <4 x float> %val, i32 100000
196 ; Test v4f32 extraction of a variable element.
197 define float @f22(<4 x float> %val, i32 %index) {
199 ; CHECK: vlgvf [[REG:%r[0-5]]], %v24, 0(%r2)
200 ; CHECK: vlvgf %v0, [[REG]], 0
202 %ret = extractelement <4 x float> %val, i32 %index
206 ; Test v2f64 extraction of the first element.
207 define double @f23(<2 x double> %val) {
209 ; CHECK: vlr %v0, %v24
211 %ret = extractelement <2 x double> %val, i32 0
215 ; Test v2f64 extraction of the last element.
216 define double @f24(<2 x double> %val) {
218 ; CHECK: vrepg %v0, %v24, 1
220 %ret = extractelement <2 x double> %val, i32 1
224 ; Test v2f64 extractions of an absurd element number. This must compile
225 ; but we don't care what it does.
226 define double @f25(<2 x double> %val) {
227 %ret = extractelement <2 x double> %val, i32 100000
231 ; Test v2f64 extraction of a variable element.
232 define double @f26(<2 x double> %val, i32 %index) {
234 ; CHECK: vlgvg [[REG:%r[0-5]]], %v24, 0(%r2)
235 ; CHECK: ldgr %f0, [[REG]]
237 %ret = extractelement <2 x double> %val, i32 %index
241 ; Test v16i8 extraction of a variable element with an offset.
242 define i8 @f27(<16 x i8> %val, i32 %index) {
244 ; CHECK: vlgvb %r2, %v24, 1(%r2)
246 %add = add i32 %index, 1
247 %ret = extractelement <16 x i8> %val, i32 %add