xref: /llvm-project/clang/test/CodeGen/arm-mve-intrinsics/get-set-lane.c (revision c5de4dd1eab00df76c1a68c5f397304ceacb71f2)
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2 // RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -O0 -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes='mem2reg,sroa,early-cse<>' | FileCheck %s
3 // RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -O0 -disable-O0-optnone -DPOLYMORPHIC -emit-llvm -o - %s | opt -S -passes='mem2reg,sroa,early-cse<>' | FileCheck %s
4 
5 // REQUIRES: aarch64-registered-target || arm-registered-target
6 
7 #include <arm_mve.h>
8 
9 // CHECK-LABEL: @test_vgetq_lane_f16(
10 // CHECK-NEXT:  entry:
11 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <8 x half> [[A:%.*]], i32 2
12 // CHECK-NEXT:    ret half [[TMP0]]
13 //
test_vgetq_lane_f16(float16x8_t a)14 float16_t test_vgetq_lane_f16(float16x8_t a)
15 {
16 #ifdef POLYMORPHIC
17     return vgetq_lane(a, 2);
18 #else /* POLYMORPHIC */
19     return vgetq_lane_f16(a, 2);
20 #endif /* POLYMORPHIC */
21 }
22 
23 // CHECK-LABEL: @test_vgetq_lane_f32(
24 // CHECK-NEXT:  entry:
25 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <4 x float> [[A:%.*]], i32 3
26 // CHECK-NEXT:    ret float [[TMP0]]
27 //
test_vgetq_lane_f32(float32x4_t a)28 float32_t test_vgetq_lane_f32(float32x4_t a)
29 {
30 #ifdef POLYMORPHIC
31     return vgetq_lane(a, 3);
32 #else /* POLYMORPHIC */
33     return vgetq_lane_f32(a, 3);
34 #endif /* POLYMORPHIC */
35 }
36 
37 // CHECK-LABEL: @test_vgetq_lane_s16(
38 // CHECK-NEXT:  entry:
39 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <8 x i16> [[A:%.*]], i32 4
40 // CHECK-NEXT:    ret i16 [[TMP0]]
41 //
test_vgetq_lane_s16(int16x8_t a)42 int16_t test_vgetq_lane_s16(int16x8_t a)
43 {
44 #ifdef POLYMORPHIC
45     return vgetq_lane(a, 4);
46 #else /* POLYMORPHIC */
47     return vgetq_lane_s16(a, 4);
48 #endif /* POLYMORPHIC */
49 }
50 
51 // CHECK-LABEL: @test_vgetq_lane_s32(
52 // CHECK-NEXT:  entry:
53 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 0
54 // CHECK-NEXT:    ret i32 [[TMP0]]
55 //
test_vgetq_lane_s32(int32x4_t a)56 int32_t test_vgetq_lane_s32(int32x4_t a)
57 {
58 #ifdef POLYMORPHIC
59     return vgetq_lane(a, 0);
60 #else /* POLYMORPHIC */
61     return vgetq_lane_s32(a, 0);
62 #endif /* POLYMORPHIC */
63 }
64 
65 // CHECK-LABEL: @test_vgetq_lane_s64(
66 // CHECK-NEXT:  entry:
67 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <2 x i64> [[A:%.*]], i32 0
68 // CHECK-NEXT:    ret i64 [[TMP0]]
69 //
test_vgetq_lane_s64(int64x2_t a)70 int64_t test_vgetq_lane_s64(int64x2_t a)
71 {
72 #ifdef POLYMORPHIC
73     return vgetq_lane(a, 0);
74 #else /* POLYMORPHIC */
75     return vgetq_lane_s64(a, 0);
76 #endif /* POLYMORPHIC */
77 }
78 
79 // CHECK-LABEL: @test_vgetq_lane_s8(
80 // CHECK-NEXT:  entry:
81 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <16 x i8> [[A:%.*]], i32 10
82 // CHECK-NEXT:    ret i8 [[TMP0]]
83 //
test_vgetq_lane_s8(int8x16_t a)84 int8_t test_vgetq_lane_s8(int8x16_t a)
85 {
86 #ifdef POLYMORPHIC
87     return vgetq_lane(a, 10);
88 #else /* POLYMORPHIC */
89     return vgetq_lane_s8(a, 10);
90 #endif /* POLYMORPHIC */
91 }
92 
93 // CHECK-LABEL: @test_vgetq_lane_u16(
94 // CHECK-NEXT:  entry:
95 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <8 x i16> [[A:%.*]], i32 3
96 // CHECK-NEXT:    ret i16 [[TMP0]]
97 //
test_vgetq_lane_u16(uint16x8_t a)98 uint16_t test_vgetq_lane_u16(uint16x8_t a)
99 {
100 #ifdef POLYMORPHIC
101     return vgetq_lane(a, 3);
102 #else /* POLYMORPHIC */
103     return vgetq_lane_u16(a, 3);
104 #endif /* POLYMORPHIC */
105 }
106 
107 // CHECK-LABEL: @test_vgetq_lane_u32(
108 // CHECK-NEXT:  entry:
109 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 3
110 // CHECK-NEXT:    ret i32 [[TMP0]]
111 //
test_vgetq_lane_u32(uint32x4_t a)112 uint32_t test_vgetq_lane_u32(uint32x4_t a)
113 {
114 #ifdef POLYMORPHIC
115     return vgetq_lane(a, 3);
116 #else /* POLYMORPHIC */
117     return vgetq_lane_u32(a, 3);
118 #endif /* POLYMORPHIC */
119 }
120 
121 // CHECK-LABEL: @test_vgetq_lane_u64(
122 // CHECK-NEXT:  entry:
123 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <2 x i64> [[A:%.*]], i32 1
124 // CHECK-NEXT:    ret i64 [[TMP0]]
125 //
test_vgetq_lane_u64(uint64x2_t a)126 uint64_t test_vgetq_lane_u64(uint64x2_t a)
127 {
128 #ifdef POLYMORPHIC
129     return vgetq_lane(a, 1);
130 #else /* POLYMORPHIC */
131     return vgetq_lane_u64(a, 1);
132 #endif /* POLYMORPHIC */
133 }
134 
135 // CHECK-LABEL: @test_vgetq_lane_u8(
136 // CHECK-NEXT:  entry:
137 // CHECK-NEXT:    [[TMP0:%.*]] = extractelement <16 x i8> [[A:%.*]], i32 1
138 // CHECK-NEXT:    ret i8 [[TMP0]]
139 //
test_vgetq_lane_u8(uint8x16_t a)140 uint8_t test_vgetq_lane_u8(uint8x16_t a)
141 {
142 #ifdef POLYMORPHIC
143     return vgetq_lane(a, 1);
144 #else /* POLYMORPHIC */
145     return vgetq_lane_u8(a, 1);
146 #endif /* POLYMORPHIC */
147 }
148 
149 // CHECK-LABEL: @test_vsetq_lane_f16(
150 // CHECK-NEXT:  entry:
151 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <8 x half> [[B:%.*]], half [[A:%.*]], i32 4
152 // CHECK-NEXT:    ret <8 x half> [[TMP0]]
153 //
test_vsetq_lane_f16(float16_t a,float16x8_t b)154 float16x8_t test_vsetq_lane_f16(float16_t a, float16x8_t b)
155 {
156 #ifdef POLYMORPHIC
157     return vsetq_lane(a, b, 4);
158 #else /* POLYMORPHIC */
159     return vsetq_lane_f16(a, b, 4);
160 #endif /* POLYMORPHIC */
161 }
162 
163 // CHECK-LABEL: @test_vsetq_lane_f32(
164 // CHECK-NEXT:  entry:
165 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <4 x float> [[B:%.*]], float [[A:%.*]], i32 2
166 // CHECK-NEXT:    ret <4 x float> [[TMP0]]
167 //
test_vsetq_lane_f32(float32_t a,float32x4_t b)168 float32x4_t test_vsetq_lane_f32(float32_t a, float32x4_t b)
169 {
170 #ifdef POLYMORPHIC
171     return vsetq_lane(a, b, 2);
172 #else /* POLYMORPHIC */
173     return vsetq_lane_f32(a, b, 2);
174 #endif /* POLYMORPHIC */
175 }
176 
177 // CHECK-LABEL: @test_vsetq_lane_s8(
178 // CHECK-NEXT:  entry:
179 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <16 x i8> [[B:%.*]], i8 [[A:%.*]], i32 12
180 // CHECK-NEXT:    ret <16 x i8> [[TMP0]]
181 //
test_vsetq_lane_s8(int8_t a,int8x16_t b)182 int8x16_t test_vsetq_lane_s8(int8_t a, int8x16_t b)
183 {
184 #ifdef POLYMORPHIC
185     return vsetq_lane(a, b, 12);
186 #else /* POLYMORPHIC */
187     return vsetq_lane_s8(a, b, 12);
188 #endif /* POLYMORPHIC */
189 }
190 
191 // CHECK-LABEL: @test_vsetq_lane_s16(
192 // CHECK-NEXT:  entry:
193 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <8 x i16> [[B:%.*]], i16 [[A:%.*]], i32 6
194 // CHECK-NEXT:    ret <8 x i16> [[TMP0]]
195 //
test_vsetq_lane_s16(int16_t a,int16x8_t b)196 int16x8_t test_vsetq_lane_s16(int16_t a, int16x8_t b)
197 {
198 #ifdef POLYMORPHIC
199     return vsetq_lane(a, b, 6);
200 #else /* POLYMORPHIC */
201     return vsetq_lane_s16(a, b, 6);
202 #endif /* POLYMORPHIC */
203 }
204 
205 // CHECK-LABEL: @test_vsetq_lane_s32(
206 // CHECK-NEXT:  entry:
207 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <4 x i32> [[B:%.*]], i32 [[A:%.*]], i32 2
208 // CHECK-NEXT:    ret <4 x i32> [[TMP0]]
209 //
test_vsetq_lane_s32(int32_t a,int32x4_t b)210 int32x4_t test_vsetq_lane_s32(int32_t a, int32x4_t b)
211 {
212 #ifdef POLYMORPHIC
213     return vsetq_lane(a, b, 2);
214 #else /* POLYMORPHIC */
215     return vsetq_lane_s32(a, b, 2);
216 #endif /* POLYMORPHIC */
217 }
218 
219 // CHECK-LABEL: @test_vsetq_lane_s64(
220 // CHECK-NEXT:  entry:
221 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <2 x i64> [[B:%.*]], i64 [[A:%.*]], i32 0
222 // CHECK-NEXT:    ret <2 x i64> [[TMP0]]
223 //
test_vsetq_lane_s64(int64_t a,int64x2_t b)224 int64x2_t test_vsetq_lane_s64(int64_t a, int64x2_t b)
225 {
226 #ifdef POLYMORPHIC
227     return vsetq_lane(a, b, 0);
228 #else /* POLYMORPHIC */
229     return vsetq_lane_s64(a, b, 0);
230 #endif /* POLYMORPHIC */
231 }
232 
233 // CHECK-LABEL: @test_vsetq_lane_u8(
234 // CHECK-NEXT:  entry:
235 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <16 x i8> [[B:%.*]], i8 [[A:%.*]], i32 2
236 // CHECK-NEXT:    ret <16 x i8> [[TMP0]]
237 //
test_vsetq_lane_u8(uint8_t a,uint8x16_t b)238 uint8x16_t test_vsetq_lane_u8(uint8_t a, uint8x16_t b)
239 {
240 #ifdef POLYMORPHIC
241     return vsetq_lane(a, b, 2);
242 #else /* POLYMORPHIC */
243     return vsetq_lane_u8(a, b, 2);
244 #endif /* POLYMORPHIC */
245 }
246 
247 // CHECK-LABEL: @test_vsetq_lane_u16(
248 // CHECK-NEXT:  entry:
249 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <8 x i16> [[B:%.*]], i16 [[A:%.*]], i32 7
250 // CHECK-NEXT:    ret <8 x i16> [[TMP0]]
251 //
test_vsetq_lane_u16(uint16_t a,uint16x8_t b)252 uint16x8_t test_vsetq_lane_u16(uint16_t a, uint16x8_t b)
253 {
254 #ifdef POLYMORPHIC
255     return vsetq_lane(a, b, 7);
256 #else /* POLYMORPHIC */
257     return vsetq_lane_u16(a, b, 7);
258 #endif /* POLYMORPHIC */
259 }
260 
261 // CHECK-LABEL: @test_vsetq_lane_u32(
262 // CHECK-NEXT:  entry:
263 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <4 x i32> [[B:%.*]], i32 [[A:%.*]], i32 0
264 // CHECK-NEXT:    ret <4 x i32> [[TMP0]]
265 //
test_vsetq_lane_u32(uint32_t a,uint32x4_t b)266 uint32x4_t test_vsetq_lane_u32(uint32_t a, uint32x4_t b)
267 {
268 #ifdef POLYMORPHIC
269     return vsetq_lane(a, b, 0);
270 #else /* POLYMORPHIC */
271     return vsetq_lane_u32(a, b, 0);
272 #endif /* POLYMORPHIC */
273 }
274 
275 // CHECK-LABEL: @test_vsetq_lane_u64(
276 // CHECK-NEXT:  entry:
277 // CHECK-NEXT:    [[TMP0:%.*]] = insertelement <2 x i64> [[B:%.*]], i64 [[A:%.*]], i32 1
278 // CHECK-NEXT:    ret <2 x i64> [[TMP0]]
279 //
test_vsetq_lane_u64(uint64_t a,uint64x2_t b)280 uint64x2_t test_vsetq_lane_u64(uint64_t a, uint64x2_t b)
281 {
282 #ifdef POLYMORPHIC
283     return vsetq_lane(a, b, 1);
284 #else /* POLYMORPHIC */
285     return vsetq_lane_u64(a, b, 1);
286 #endif /* POLYMORPHIC */
287 }
288