xref: /llvm-project/clang/test/CodeGen/arm-mve-intrinsics/vhaddq.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 | 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 | FileCheck %s
4 
5 // REQUIRES: aarch64-registered-target || arm-registered-target
6 
7 #include <arm_mve.h>
8 
9 // CHECK-LABEL: @test_vhaddq_u8(
10 // CHECK-NEXT:  entry:
11 // CHECK-NEXT:    [[TMP0:%.*]] = call <16 x i8> @llvm.arm.mve.vhadd.v16i8(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], i32 1)
12 // CHECK-NEXT:    ret <16 x i8> [[TMP0]]
13 //
test_vhaddq_u8(uint8x16_t a,uint8x16_t b)14 uint8x16_t test_vhaddq_u8(uint8x16_t a, uint8x16_t b)
15 {
16 #ifdef POLYMORPHIC
17     return vhaddq(a, b);
18 #else /* POLYMORPHIC */
19     return vhaddq_u8(a, b);
20 #endif /* POLYMORPHIC */
21 }
22 
23 // CHECK-LABEL: @test_vhaddq_s16(
24 // CHECK-NEXT:  entry:
25 // CHECK-NEXT:    [[TMP0:%.*]] = call <8 x i16> @llvm.arm.mve.vhadd.v8i16(<8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]], i32 0)
26 // CHECK-NEXT:    ret <8 x i16> [[TMP0]]
27 //
test_vhaddq_s16(int16x8_t a,int16x8_t b)28 int16x8_t test_vhaddq_s16(int16x8_t a, int16x8_t b)
29 {
30 #ifdef POLYMORPHIC
31     return vhaddq(a, b);
32 #else /* POLYMORPHIC */
33     return vhaddq_s16(a, b);
34 #endif /* POLYMORPHIC */
35 }
36 
37 // CHECK-LABEL: @test_vhaddq_u32(
38 // CHECK-NEXT:  entry:
39 // CHECK-NEXT:    [[TMP0:%.*]] = call <4 x i32> @llvm.arm.mve.vhadd.v4i32(<4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], i32 1)
40 // CHECK-NEXT:    ret <4 x i32> [[TMP0]]
41 //
test_vhaddq_u32(uint32x4_t a,uint32x4_t b)42 uint32x4_t test_vhaddq_u32(uint32x4_t a, uint32x4_t b)
43 {
44 #ifdef POLYMORPHIC
45     return vhaddq(a, b);
46 #else /* POLYMORPHIC */
47     return vhaddq_u32(a, b);
48 #endif /* POLYMORPHIC */
49 }
50 
51 // CHECK-LABEL: @test_vhaddq_m_s8(
52 // CHECK-NEXT:  entry:
53 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
54 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
55 // CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.arm.mve.hadd.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], i32 0, <16 x i1> [[TMP1]], <16 x i8> [[INACTIVE:%.*]])
56 // CHECK-NEXT:    ret <16 x i8> [[TMP2]]
57 //
test_vhaddq_m_s8(int8x16_t inactive,int8x16_t a,int8x16_t b,mve_pred16_t p)58 int8x16_t test_vhaddq_m_s8(int8x16_t inactive, int8x16_t a, int8x16_t b, mve_pred16_t p)
59 {
60 #ifdef POLYMORPHIC
61     return vhaddq_m(inactive, a, b, p);
62 #else /* POLYMORPHIC */
63     return vhaddq_m_s8(inactive, a, b, p);
64 #endif /* POLYMORPHIC */
65 }
66 
67 // CHECK-LABEL: @test_vhaddq_m_u16(
68 // CHECK-NEXT:  entry:
69 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
70 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
71 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.hadd.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]], i32 1, <8 x i1> [[TMP1]], <8 x i16> [[INACTIVE:%.*]])
72 // CHECK-NEXT:    ret <8 x i16> [[TMP2]]
73 //
test_vhaddq_m_u16(uint16x8_t inactive,uint16x8_t a,uint16x8_t b,mve_pred16_t p)74 uint16x8_t test_vhaddq_m_u16(uint16x8_t inactive, uint16x8_t a, uint16x8_t b, mve_pred16_t p)
75 {
76 #ifdef POLYMORPHIC
77     return vhaddq_m(inactive, a, b, p);
78 #else /* POLYMORPHIC */
79     return vhaddq_m_u16(inactive, a, b, p);
80 #endif /* POLYMORPHIC */
81 }
82 
83 // CHECK-LABEL: @test_vhaddq_m_s32(
84 // CHECK-NEXT:  entry:
85 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
86 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
87 // CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i32> @llvm.arm.mve.hadd.predicated.v4i32.v4i1(<4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], i32 0, <4 x i1> [[TMP1]], <4 x i32> [[INACTIVE:%.*]])
88 // CHECK-NEXT:    ret <4 x i32> [[TMP2]]
89 //
test_vhaddq_m_s32(int32x4_t inactive,int32x4_t a,int32x4_t b,mve_pred16_t p)90 int32x4_t test_vhaddq_m_s32(int32x4_t inactive, int32x4_t a, int32x4_t b, mve_pred16_t p)
91 {
92 #ifdef POLYMORPHIC
93     return vhaddq_m(inactive, a, b, p);
94 #else /* POLYMORPHIC */
95     return vhaddq_m_s32(inactive, a, b, p);
96 #endif /* POLYMORPHIC */
97 }
98 
99 // CHECK-LABEL: @test_vhaddq_x_u8(
100 // CHECK-NEXT:  entry:
101 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
102 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
103 // CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.arm.mve.hadd.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], i32 1, <16 x i1> [[TMP1]], <16 x i8> undef)
104 // CHECK-NEXT:    ret <16 x i8> [[TMP2]]
105 //
test_vhaddq_x_u8(uint8x16_t a,uint8x16_t b,mve_pred16_t p)106 uint8x16_t test_vhaddq_x_u8(uint8x16_t a, uint8x16_t b, mve_pred16_t p)
107 {
108 #ifdef POLYMORPHIC
109     return vhaddq_x(a, b, p);
110 #else /* POLYMORPHIC */
111     return vhaddq_x_u8(a, b, p);
112 #endif /* POLYMORPHIC */
113 }
114 
115 // CHECK-LABEL: @test_vhaddq_x_s16(
116 // CHECK-NEXT:  entry:
117 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
118 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
119 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.hadd.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]], i32 0, <8 x i1> [[TMP1]], <8 x i16> undef)
120 // CHECK-NEXT:    ret <8 x i16> [[TMP2]]
121 //
test_vhaddq_x_s16(int16x8_t a,int16x8_t b,mve_pred16_t p)122 int16x8_t test_vhaddq_x_s16(int16x8_t a, int16x8_t b, mve_pred16_t p)
123 {
124 #ifdef POLYMORPHIC
125     return vhaddq_x(a, b, p);
126 #else /* POLYMORPHIC */
127     return vhaddq_x_s16(a, b, p);
128 #endif /* POLYMORPHIC */
129 }
130 
131 // CHECK-LABEL: @test_vhaddq_x_u32(
132 // CHECK-NEXT:  entry:
133 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
134 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
135 // CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i32> @llvm.arm.mve.hadd.predicated.v4i32.v4i1(<4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], i32 1, <4 x i1> [[TMP1]], <4 x i32> undef)
136 // CHECK-NEXT:    ret <4 x i32> [[TMP2]]
137 //
test_vhaddq_x_u32(uint32x4_t a,uint32x4_t b,mve_pred16_t p)138 uint32x4_t test_vhaddq_x_u32(uint32x4_t a, uint32x4_t b, mve_pred16_t p)
139 {
140 #ifdef POLYMORPHIC
141     return vhaddq_x(a, b, p);
142 #else /* POLYMORPHIC */
143     return vhaddq_x_u32(a, b, p);
144 #endif /* POLYMORPHIC */
145 }
146 
147 // CHECK-LABEL: @test_vhaddq_n_u8(
148 // CHECK-NEXT:  entry:
149 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <16 x i8> poison, i8 [[B:%.*]], i64 0
150 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <16 x i8> [[DOTSPLATINSERT]], <16 x i8> poison, <16 x i32> zeroinitializer
151 // CHECK-NEXT:    [[TMP0:%.*]] = call <16 x i8> @llvm.arm.mve.vhadd.v16i8(<16 x i8> [[A:%.*]], <16 x i8> [[DOTSPLAT]], i32 1)
152 // CHECK-NEXT:    ret <16 x i8> [[TMP0]]
153 //
test_vhaddq_n_u8(uint8x16_t a,uint8_t b)154 uint8x16_t test_vhaddq_n_u8(uint8x16_t a, uint8_t b)
155 {
156 #ifdef POLYMORPHIC
157     return vhaddq(a, b);
158 #else /* POLYMORPHIC */
159     return vhaddq_n_u8(a, b);
160 #endif /* POLYMORPHIC */
161 }
162 
163 // CHECK-LABEL: @test_vhaddq_n_s16(
164 // CHECK-NEXT:  entry:
165 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x i16> poison, i16 [[B:%.*]], i64 0
166 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x i16> [[DOTSPLATINSERT]], <8 x i16> poison, <8 x i32> zeroinitializer
167 // CHECK-NEXT:    [[TMP0:%.*]] = call <8 x i16> @llvm.arm.mve.vhadd.v8i16(<8 x i16> [[A:%.*]], <8 x i16> [[DOTSPLAT]], i32 0)
168 // CHECK-NEXT:    ret <8 x i16> [[TMP0]]
169 //
test_vhaddq_n_s16(int16x8_t a,int16_t b)170 int16x8_t test_vhaddq_n_s16(int16x8_t a, int16_t b)
171 {
172 #ifdef POLYMORPHIC
173     return vhaddq(a, b);
174 #else /* POLYMORPHIC */
175     return vhaddq_n_s16(a, b);
176 #endif /* POLYMORPHIC */
177 }
178 
179 // CHECK-LABEL: @test_vhaddq_n_u32(
180 // CHECK-NEXT:  entry:
181 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[B:%.*]], i64 0
182 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <4 x i32> [[DOTSPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer
183 // CHECK-NEXT:    [[TMP0:%.*]] = call <4 x i32> @llvm.arm.mve.vhadd.v4i32(<4 x i32> [[A:%.*]], <4 x i32> [[DOTSPLAT]], i32 1)
184 // CHECK-NEXT:    ret <4 x i32> [[TMP0]]
185 //
test_vhaddq_n_u32(uint32x4_t a,uint32_t b)186 uint32x4_t test_vhaddq_n_u32(uint32x4_t a, uint32_t b)
187 {
188 #ifdef POLYMORPHIC
189     return vhaddq(a, b);
190 #else /* POLYMORPHIC */
191     return vhaddq_n_u32(a, b);
192 #endif /* POLYMORPHIC */
193 }
194 
195 // CHECK-LABEL: @test_vhaddq_m_n_s8(
196 // CHECK-NEXT:  entry:
197 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <16 x i8> poison, i8 [[B:%.*]], i64 0
198 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <16 x i8> [[DOTSPLATINSERT]], <16 x i8> poison, <16 x i32> zeroinitializer
199 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
200 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
201 // CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.arm.mve.hadd.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> [[DOTSPLAT]], i32 0, <16 x i1> [[TMP1]], <16 x i8> [[INACTIVE:%.*]])
202 // CHECK-NEXT:    ret <16 x i8> [[TMP2]]
203 //
test_vhaddq_m_n_s8(int8x16_t inactive,int8x16_t a,int8_t b,mve_pred16_t p)204 int8x16_t test_vhaddq_m_n_s8(int8x16_t inactive, int8x16_t a, int8_t b, mve_pred16_t p)
205 {
206 #ifdef POLYMORPHIC
207     return vhaddq_m(inactive, a, b, p);
208 #else /* POLYMORPHIC */
209     return vhaddq_m_n_s8(inactive, a, b, p);
210 #endif /* POLYMORPHIC */
211 }
212 
213 // CHECK-LABEL: @test_vhaddq_m_n_u16(
214 // CHECK-NEXT:  entry:
215 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x i16> poison, i16 [[B:%.*]], i64 0
216 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x i16> [[DOTSPLATINSERT]], <8 x i16> poison, <8 x i32> zeroinitializer
217 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
218 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
219 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.hadd.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> [[DOTSPLAT]], i32 1, <8 x i1> [[TMP1]], <8 x i16> [[INACTIVE:%.*]])
220 // CHECK-NEXT:    ret <8 x i16> [[TMP2]]
221 //
test_vhaddq_m_n_u16(uint16x8_t inactive,uint16x8_t a,uint16_t b,mve_pred16_t p)222 uint16x8_t test_vhaddq_m_n_u16(uint16x8_t inactive, uint16x8_t a, uint16_t b, mve_pred16_t p)
223 {
224 #ifdef POLYMORPHIC
225     return vhaddq_m(inactive, a, b, p);
226 #else /* POLYMORPHIC */
227     return vhaddq_m_n_u16(inactive, a, b, p);
228 #endif /* POLYMORPHIC */
229 }
230 
231 // CHECK-LABEL: @test_vhaddq_m_n_s32(
232 // CHECK-NEXT:  entry:
233 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[B:%.*]], i64 0
234 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <4 x i32> [[DOTSPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer
235 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
236 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
237 // CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i32> @llvm.arm.mve.hadd.predicated.v4i32.v4i1(<4 x i32> [[A:%.*]], <4 x i32> [[DOTSPLAT]], i32 0, <4 x i1> [[TMP1]], <4 x i32> [[INACTIVE:%.*]])
238 // CHECK-NEXT:    ret <4 x i32> [[TMP2]]
239 //
test_vhaddq_m_n_s32(int32x4_t inactive,int32x4_t a,int32_t b,mve_pred16_t p)240 int32x4_t test_vhaddq_m_n_s32(int32x4_t inactive, int32x4_t a, int32_t b, mve_pred16_t p)
241 {
242 #ifdef POLYMORPHIC
243     return vhaddq_m(inactive, a, b, p);
244 #else /* POLYMORPHIC */
245     return vhaddq_m_n_s32(inactive, a, b, p);
246 #endif /* POLYMORPHIC */
247 }
248 
249 // CHECK-LABEL: @test_vhaddq_x_n_u8(
250 // CHECK-NEXT:  entry:
251 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <16 x i8> poison, i8 [[B:%.*]], i64 0
252 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <16 x i8> [[DOTSPLATINSERT]], <16 x i8> poison, <16 x i32> zeroinitializer
253 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
254 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
255 // CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.arm.mve.hadd.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> [[DOTSPLAT]], i32 1, <16 x i1> [[TMP1]], <16 x i8> undef)
256 // CHECK-NEXT:    ret <16 x i8> [[TMP2]]
257 //
test_vhaddq_x_n_u8(uint8x16_t a,uint8_t b,mve_pred16_t p)258 uint8x16_t test_vhaddq_x_n_u8(uint8x16_t a, uint8_t b, mve_pred16_t p)
259 {
260 #ifdef POLYMORPHIC
261     return vhaddq_x(a, b, p);
262 #else /* POLYMORPHIC */
263     return vhaddq_x_n_u8(a, b, p);
264 #endif /* POLYMORPHIC */
265 }
266 
267 // CHECK-LABEL: @test_vhaddq_x_n_s16(
268 // CHECK-NEXT:  entry:
269 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x i16> poison, i16 [[B:%.*]], i64 0
270 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x i16> [[DOTSPLATINSERT]], <8 x i16> poison, <8 x i32> zeroinitializer
271 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
272 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
273 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.hadd.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> [[DOTSPLAT]], i32 0, <8 x i1> [[TMP1]], <8 x i16> undef)
274 // CHECK-NEXT:    ret <8 x i16> [[TMP2]]
275 //
test_vhaddq_x_n_s16(int16x8_t a,int16_t b,mve_pred16_t p)276 int16x8_t test_vhaddq_x_n_s16(int16x8_t a, int16_t b, mve_pred16_t p)
277 {
278 #ifdef POLYMORPHIC
279     return vhaddq_x(a, b, p);
280 #else /* POLYMORPHIC */
281     return vhaddq_x_n_s16(a, b, p);
282 #endif /* POLYMORPHIC */
283 }
284 
285 // CHECK-LABEL: @test_vhaddq_x_n_u32(
286 // CHECK-NEXT:  entry:
287 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[B:%.*]], i64 0
288 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <4 x i32> [[DOTSPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer
289 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
290 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
291 // CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i32> @llvm.arm.mve.hadd.predicated.v4i32.v4i1(<4 x i32> [[A:%.*]], <4 x i32> [[DOTSPLAT]], i32 1, <4 x i1> [[TMP1]], <4 x i32> undef)
292 // CHECK-NEXT:    ret <4 x i32> [[TMP2]]
293 //
test_vhaddq_x_n_u32(uint32x4_t a,uint32_t b,mve_pred16_t p)294 uint32x4_t test_vhaddq_x_n_u32(uint32x4_t a, uint32_t b, mve_pred16_t p)
295 {
296 #ifdef POLYMORPHIC
297     return vhaddq_x(a, b, p);
298 #else /* POLYMORPHIC */
299     return vhaddq_x_n_u32(a, b, p);
300 #endif /* POLYMORPHIC */
301 }
302