xref: /llvm-project/clang/test/CodeGen/arm-mve-intrinsics/vaddq.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=sroa | 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=sroa | FileCheck %s
4 
5 // REQUIRES: aarch64-registered-target || arm-registered-target
6 
7 #include <arm_mve.h>
8 
9 // CHECK-LABEL: @test_vaddq_u32(
10 // CHECK-NEXT:  entry:
11 // CHECK-NEXT:    [[TMP0:%.*]] = add <4 x i32> [[A:%.*]], [[B:%.*]]
12 // CHECK-NEXT:    ret <4 x i32> [[TMP0]]
13 //
test_vaddq_u32(uint32x4_t a,uint32x4_t b)14 uint32x4_t test_vaddq_u32(uint32x4_t a, uint32x4_t b)
15 {
16 #ifdef POLYMORPHIC
17     return vaddq(a, b);
18 #else /* POLYMORPHIC */
19     return vaddq_u32(a, b);
20 #endif /* POLYMORPHIC */
21 }
22 
23 // CHECK-LABEL: @test_vaddq_f16(
24 // CHECK-NEXT:  entry:
25 // CHECK-NEXT:    [[TMP0:%.*]] = fadd <8 x half> [[A:%.*]], [[B:%.*]]
26 // CHECK-NEXT:    ret <8 x half> [[TMP0]]
27 //
test_vaddq_f16(float16x8_t a,float16x8_t b)28 float16x8_t test_vaddq_f16(float16x8_t a, float16x8_t b)
29 {
30 #ifdef POLYMORPHIC
31     return vaddq(a, b);
32 #else /* POLYMORPHIC */
33     return vaddq_f16(a, b);
34 #endif /* POLYMORPHIC */
35 }
36 
37 // CHECK-LABEL: @test_vaddq_m_s8(
38 // CHECK-NEXT:  entry:
39 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
40 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
41 // CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.arm.mve.add.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], <16 x i1> [[TMP1]], <16 x i8> [[INACTIVE:%.*]])
42 // CHECK-NEXT:    ret <16 x i8> [[TMP2]]
43 //
test_vaddq_m_s8(int8x16_t inactive,int8x16_t a,int8x16_t b,mve_pred16_t p)44 int8x16_t test_vaddq_m_s8(int8x16_t inactive, int8x16_t a, int8x16_t b, mve_pred16_t p)
45 {
46 #ifdef POLYMORPHIC
47     return vaddq_m(inactive, a, b, p);
48 #else /* POLYMORPHIC */
49     return vaddq_m_s8(inactive, a, b, p);
50 #endif /* POLYMORPHIC */
51 }
52 
53 // CHECK-LABEL: @test_vaddq_m_f32(
54 // CHECK-NEXT:  entry:
55 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
56 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
57 // CHECK-NEXT:    [[TMP2:%.*]] = call <4 x float> @llvm.arm.mve.add.predicated.v4f32.v4i1(<4 x float> [[A:%.*]], <4 x float> [[B:%.*]], <4 x i1> [[TMP1]], <4 x float> [[INACTIVE:%.*]])
58 // CHECK-NEXT:    ret <4 x float> [[TMP2]]
59 //
test_vaddq_m_f32(float32x4_t inactive,float32x4_t a,float32x4_t b,mve_pred16_t p)60 float32x4_t test_vaddq_m_f32(float32x4_t inactive, float32x4_t a, float32x4_t b, mve_pred16_t p)
61 {
62 #ifdef POLYMORPHIC
63     return vaddq_m(inactive, a, b, p);
64 #else /* POLYMORPHIC */
65     return vaddq_m_f32(inactive, a, b, p);
66 #endif /* POLYMORPHIC */
67 }
68 
69 // CHECK-LABEL: @test_vaddq_x_u16(
70 // CHECK-NEXT:  entry:
71 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
72 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
73 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.add.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]], <8 x i1> [[TMP1]], <8 x i16> undef)
74 // CHECK-NEXT:    ret <8 x i16> [[TMP2]]
75 //
test_vaddq_x_u16(uint16x8_t a,uint16x8_t b,mve_pred16_t p)76 uint16x8_t test_vaddq_x_u16(uint16x8_t a, uint16x8_t b, mve_pred16_t p)
77 {
78 #ifdef POLYMORPHIC
79     return vaddq_x(a, b, p);
80 #else /* POLYMORPHIC */
81     return vaddq_x_u16(a, b, p);
82 #endif /* POLYMORPHIC */
83 }
84 
85 // CHECK-LABEL: @test_vaddq_x_f16(
86 // CHECK-NEXT:  entry:
87 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
88 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
89 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x half> @llvm.arm.mve.add.predicated.v8f16.v8i1(<8 x half> [[A:%.*]], <8 x half> [[B:%.*]], <8 x i1> [[TMP1]], <8 x half> undef)
90 // CHECK-NEXT:    ret <8 x half> [[TMP2]]
91 //
test_vaddq_x_f16(float16x8_t a,float16x8_t b,mve_pred16_t p)92 float16x8_t test_vaddq_x_f16(float16x8_t a, float16x8_t b, mve_pred16_t p)
93 {
94 #ifdef POLYMORPHIC
95     return vaddq_x(a, b, p);
96 #else /* POLYMORPHIC */
97     return vaddq_x_f16(a, b, p);
98 #endif /* POLYMORPHIC */
99 }
100 
101 // CHECK-LABEL: @test_vaddq_n_u32(
102 // CHECK-NEXT:  entry:
103 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[B:%.*]], i64 0
104 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <4 x i32> [[DOTSPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer
105 // CHECK-NEXT:    [[TMP0:%.*]] = add <4 x i32> [[A:%.*]], [[DOTSPLAT]]
106 // CHECK-NEXT:    ret <4 x i32> [[TMP0]]
107 //
test_vaddq_n_u32(uint32x4_t a,uint32_t b)108 uint32x4_t test_vaddq_n_u32(uint32x4_t a, uint32_t b)
109 {
110 #ifdef POLYMORPHIC
111     return vaddq(a, b);
112 #else /* POLYMORPHIC */
113     return vaddq_n_u32(a, b);
114 #endif /* POLYMORPHIC */
115 }
116 
117 // CHECK-LABEL: @test_vaddq_n_f16(
118 // CHECK-NEXT:  entry:
119 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x half> poison, half [[B:%.*]], i64 0
120 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x half> [[DOTSPLATINSERT]], <8 x half> poison, <8 x i32> zeroinitializer
121 // CHECK-NEXT:    [[TMP0:%.*]] = fadd <8 x half> [[A:%.*]], [[DOTSPLAT]]
122 // CHECK-NEXT:    ret <8 x half> [[TMP0]]
123 //
test_vaddq_n_f16(float16x8_t a,float16_t b)124 float16x8_t test_vaddq_n_f16(float16x8_t a, float16_t b)
125 {
126 #ifdef POLYMORPHIC
127     return vaddq(a, b);
128 #else /* POLYMORPHIC */
129     return vaddq_n_f16(a, b);
130 #endif /* POLYMORPHIC */
131 }
132 
133 // CHECK-LABEL: @test_vaddq_m_n_s8(
134 // CHECK-NEXT:  entry:
135 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <16 x i8> poison, i8 [[B:%.*]], i64 0
136 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <16 x i8> [[DOTSPLATINSERT]], <16 x i8> poison, <16 x i32> zeroinitializer
137 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
138 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
139 // CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.arm.mve.add.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> [[DOTSPLAT]], <16 x i1> [[TMP1]], <16 x i8> [[INACTIVE:%.*]])
140 // CHECK-NEXT:    ret <16 x i8> [[TMP2]]
141 //
test_vaddq_m_n_s8(int8x16_t inactive,int8x16_t a,int8_t b,mve_pred16_t p)142 int8x16_t test_vaddq_m_n_s8(int8x16_t inactive, int8x16_t a, int8_t b, mve_pred16_t p)
143 {
144 #ifdef POLYMORPHIC
145     return vaddq_m(inactive, a, b, p);
146 #else /* POLYMORPHIC */
147     return vaddq_m_n_s8(inactive, a, b, p);
148 #endif /* POLYMORPHIC */
149 }
150 
151 // CHECK-LABEL: @test_vaddq_m_n_f32(
152 // CHECK-NEXT:  entry:
153 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <4 x float> poison, float [[B:%.*]], i64 0
154 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <4 x float> [[DOTSPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
155 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
156 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
157 // CHECK-NEXT:    [[TMP2:%.*]] = call <4 x float> @llvm.arm.mve.add.predicated.v4f32.v4i1(<4 x float> [[A:%.*]], <4 x float> [[DOTSPLAT]], <4 x i1> [[TMP1]], <4 x float> [[INACTIVE:%.*]])
158 // CHECK-NEXT:    ret <4 x float> [[TMP2]]
159 //
test_vaddq_m_n_f32(float32x4_t inactive,float32x4_t a,float32_t b,mve_pred16_t p)160 float32x4_t test_vaddq_m_n_f32(float32x4_t inactive, float32x4_t a, float32_t b, mve_pred16_t p)
161 {
162 #ifdef POLYMORPHIC
163     return vaddq_m(inactive, a, b, p);
164 #else /* POLYMORPHIC */
165     return vaddq_m_n_f32(inactive, a, b, p);
166 #endif /* POLYMORPHIC */
167 }
168 
169 // CHECK-LABEL: @test_vaddq_x_n_u16(
170 // CHECK-NEXT:  entry:
171 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x i16> poison, i16 [[B:%.*]], i64 0
172 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x i16> [[DOTSPLATINSERT]], <8 x i16> poison, <8 x i32> zeroinitializer
173 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
174 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
175 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.add.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> [[DOTSPLAT]], <8 x i1> [[TMP1]], <8 x i16> undef)
176 // CHECK-NEXT:    ret <8 x i16> [[TMP2]]
177 //
test_vaddq_x_n_u16(uint16x8_t a,uint16_t b,mve_pred16_t p)178 uint16x8_t test_vaddq_x_n_u16(uint16x8_t a, uint16_t b, mve_pred16_t p)
179 {
180 #ifdef POLYMORPHIC
181     return vaddq_x(a, b, p);
182 #else /* POLYMORPHIC */
183     return vaddq_x_n_u16(a, b, p);
184 #endif /* POLYMORPHIC */
185 }
186 
187 // CHECK-LABEL: @test_vaddq_x_n_f16(
188 // CHECK-NEXT:  entry:
189 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x half> poison, half [[B:%.*]], i64 0
190 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x half> [[DOTSPLATINSERT]], <8 x half> poison, <8 x i32> zeroinitializer
191 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
192 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
193 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x half> @llvm.arm.mve.add.predicated.v8f16.v8i1(<8 x half> [[A:%.*]], <8 x half> [[DOTSPLAT]], <8 x i1> [[TMP1]], <8 x half> undef)
194 // CHECK-NEXT:    ret <8 x half> [[TMP2]]
195 //
test_vaddq_x_n_f16(float16x8_t a,float16_t b,mve_pred16_t p)196 float16x8_t test_vaddq_x_n_f16(float16x8_t a, float16_t b, mve_pred16_t p)
197 {
198 #ifdef POLYMORPHIC
199     return vaddq_x(a, b, p);
200 #else /* POLYMORPHIC */
201     return vaddq_x_n_f16(a, b, p);
202 #endif /* POLYMORPHIC */
203 }
204