1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -emit-llvm -o - %s | FileCheck %s
4 // FIXME: This demonstrates elementwise builtins are broken for strictfp and
5 // produce unconstrained intrinsics
7 typedef float float4
__attribute__((ext_vector_type(4)));
9 // Sanity check we're getting constrained ops for a non-builtin.
10 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z11strict_faddDv4_fS_
11 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
13 // CHECK-NEXT: [[ADD:%.*]] = tail call <4 x float> @llvm.experimental.constrained.fadd.v4f32(<4 x float> [[A]], <4 x float> [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR4:[0-9]+]]
14 // CHECK-NEXT: ret <4 x float> [[ADD]]
16 float4
strict_fadd(float4 a
, float4 b
) {
20 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_absDv4_f
21 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {
23 // CHECK-NEXT: [[ELT_ABS:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> [[A]]) #[[ATTR4]]
24 // CHECK-NEXT: ret <4 x float> [[ELT_ABS]]
26 float4
strict_elementwise_abs(float4 a
) {
27 return __builtin_elementwise_abs(a
);
30 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_maxDv4_fS_
31 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR0]] {
33 // CHECK-NEXT: [[ELT_MAX:%.*]] = tail call <4 x float> @llvm.experimental.constrained.maxnum.v4f32(<4 x float> [[A]], <4 x float> [[B]], metadata !"fpexcept.strict") #[[ATTR4]]
34 // CHECK-NEXT: ret <4 x float> [[ELT_MAX]]
36 float4
strict_elementwise_max(float4 a
, float4 b
) {
37 return __builtin_elementwise_max(a
, b
);
40 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_minDv4_fS_
41 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR0]] {
43 // CHECK-NEXT: [[ELT_MIN:%.*]] = tail call <4 x float> @llvm.experimental.constrained.minnum.v4f32(<4 x float> [[A]], <4 x float> [[B]], metadata !"fpexcept.strict") #[[ATTR4]]
44 // CHECK-NEXT: ret <4 x float> [[ELT_MIN]]
46 float4
strict_elementwise_min(float4 a
, float4 b
) {
47 return __builtin_elementwise_min(a
, b
);
50 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z26strict_elementwise_maximumDv4_fS_
51 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] {
53 // CHECK-NEXT: [[ELT_MAXIMUM:%.*]] = tail call <4 x float> @llvm.maximum.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]]
54 // CHECK-NEXT: ret <4 x float> [[ELT_MAXIMUM]]
56 float4
strict_elementwise_maximum(float4 a
, float4 b
) {
57 return __builtin_elementwise_maximum(a
, b
);
60 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z26strict_elementwise_minimumDv4_fS_
61 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] {
63 // CHECK-NEXT: [[ELT_MINIMUM:%.*]] = tail call <4 x float> @llvm.minimum.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]]
64 // CHECK-NEXT: ret <4 x float> [[ELT_MINIMUM]]
66 float4
strict_elementwise_minimum(float4 a
, float4 b
) {
67 return __builtin_elementwise_minimum(a
, b
);
70 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_ceilDv4_f
71 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
73 // CHECK-NEXT: [[ELT_CEIL:%.*]] = tail call <4 x float> @llvm.ceil.v4f32(<4 x float> [[A]]) #[[ATTR4]]
74 // CHECK-NEXT: ret <4 x float> [[ELT_CEIL]]
76 float4
strict_elementwise_ceil(float4 a
) {
77 return __builtin_elementwise_ceil(a
);
80 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_acosDv4_f
81 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
83 // CHECK-NEXT: [[ELT_ACOS:%.*]] = tail call <4 x float> @llvm.acos.v4f32(<4 x float> [[A]]) #[[ATTR4]]
84 // CHECK-NEXT: ret <4 x float> [[ELT_ACOS]]
86 float4
strict_elementwise_acos(float4 a
) {
87 return __builtin_elementwise_acos(a
);
90 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_cosDv4_f
91 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
93 // CHECK-NEXT: [[ELT_COS:%.*]] = tail call <4 x float> @llvm.cos.v4f32(<4 x float> [[A]]) #[[ATTR4]]
94 // CHECK-NEXT: ret <4 x float> [[ELT_COS]]
96 float4
strict_elementwise_cos(float4 a
) {
97 return __builtin_elementwise_cos(a
);
100 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_coshDv4_f
101 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
102 // CHECK-NEXT: entry:
103 // CHECK-NEXT: [[ELT_COSH:%.*]] = tail call <4 x float> @llvm.cosh.v4f32(<4 x float> [[A]]) #[[ATTR4]]
104 // CHECK-NEXT: ret <4 x float> [[ELT_COSH]]
106 float4
strict_elementwise_cosh(float4 a
) {
107 return __builtin_elementwise_cosh(a
);
110 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_expDv4_f
111 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
112 // CHECK-NEXT: entry:
113 // CHECK-NEXT: [[ELT_EXP:%.*]] = tail call <4 x float> @llvm.exp.v4f32(<4 x float> [[A]]) #[[ATTR4]]
114 // CHECK-NEXT: ret <4 x float> [[ELT_EXP]]
116 float4
strict_elementwise_exp(float4 a
) {
117 return __builtin_elementwise_exp(a
);
120 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_exp2Dv4_f
121 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
122 // CHECK-NEXT: entry:
123 // CHECK-NEXT: [[ELT_EXP2:%.*]] = tail call <4 x float> @llvm.exp2.v4f32(<4 x float> [[A]]) #[[ATTR4]]
124 // CHECK-NEXT: ret <4 x float> [[ELT_EXP2]]
126 float4
strict_elementwise_exp2(float4 a
) {
127 return __builtin_elementwise_exp2(a
);
130 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z24strict_elementwise_floorDv4_f
131 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
132 // CHECK-NEXT: entry:
133 // CHECK-NEXT: [[ELT_FLOOR:%.*]] = tail call <4 x float> @llvm.floor.v4f32(<4 x float> [[A]]) #[[ATTR4]]
134 // CHECK-NEXT: ret <4 x float> [[ELT_FLOOR]]
136 float4
strict_elementwise_floor(float4 a
) {
137 return __builtin_elementwise_floor(a
);
140 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_logDv4_f
141 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
142 // CHECK-NEXT: entry:
143 // CHECK-NEXT: [[ELT_LOG:%.*]] = tail call <4 x float> @llvm.log.v4f32(<4 x float> [[A]]) #[[ATTR4]]
144 // CHECK-NEXT: ret <4 x float> [[ELT_LOG]]
146 float4
strict_elementwise_log(float4 a
) {
147 return __builtin_elementwise_log(a
);
150 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_log2Dv4_f
151 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
152 // CHECK-NEXT: entry:
153 // CHECK-NEXT: [[ELT_LOG2:%.*]] = tail call <4 x float> @llvm.log2.v4f32(<4 x float> [[A]]) #[[ATTR4]]
154 // CHECK-NEXT: ret <4 x float> [[ELT_LOG2]]
156 float4
strict_elementwise_log2(float4 a
) {
157 return __builtin_elementwise_log2(a
);
160 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z24strict_elementwise_log10Dv4_f
161 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
162 // CHECK-NEXT: entry:
163 // CHECK-NEXT: [[ELT_LOG2:%.*]] = tail call <4 x float> @llvm.log2.v4f32(<4 x float> [[A]]) #[[ATTR4]]
164 // CHECK-NEXT: ret <4 x float> [[ELT_LOG2]]
166 float4
strict_elementwise_log10(float4 a
) {
167 return __builtin_elementwise_log2(a
);
170 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z28strict_elementwise_roundevenDv4_f
171 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
172 // CHECK-NEXT: entry:
173 // CHECK-NEXT: [[ELT_ROUNDEVEN:%.*]] = tail call <4 x float> @llvm.roundeven.v4f32(<4 x float> [[A]]) #[[ATTR4]]
174 // CHECK-NEXT: ret <4 x float> [[ELT_ROUNDEVEN]]
176 float4
strict_elementwise_roundeven(float4 a
) {
177 return __builtin_elementwise_roundeven(a
);
180 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z24strict_elementwise_roundDv4_f
181 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
182 // CHECK-NEXT: entry:
183 // CHECK-NEXT: [[ELT_ROUND:%.*]] = tail call <4 x float> @llvm.round.v4f32(<4 x float> [[A]]) #[[ATTR4]]
184 // CHECK-NEXT: ret <4 x float> [[ELT_ROUND]]
186 float4
strict_elementwise_round(float4 a
) {
187 return __builtin_elementwise_round(a
);
190 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_rintDv4_f
191 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
192 // CHECK-NEXT: entry:
193 // CHECK-NEXT: [[ELT_RINT:%.*]] = tail call <4 x float> @llvm.rint.v4f32(<4 x float> [[A]]) #[[ATTR4]]
194 // CHECK-NEXT: ret <4 x float> [[ELT_RINT]]
196 float4
strict_elementwise_rint(float4 a
) {
197 return __builtin_elementwise_rint(a
);
200 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z28strict_elementwise_nearbyintDv4_f
201 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
202 // CHECK-NEXT: entry:
203 // CHECK-NEXT: [[ELT_NEARBYINT:%.*]] = tail call <4 x float> @llvm.nearbyint.v4f32(<4 x float> [[A]]) #[[ATTR4]]
204 // CHECK-NEXT: ret <4 x float> [[ELT_NEARBYINT]]
206 float4
strict_elementwise_nearbyint(float4 a
) {
207 return __builtin_elementwise_nearbyint(a
);
210 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_asinDv4_f
211 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
212 // CHECK-NEXT: entry:
213 // CHECK-NEXT: [[ELT_ASIN:%.*]] = tail call <4 x float> @llvm.asin.v4f32(<4 x float> [[A]]) #[[ATTR4]]
214 // CHECK-NEXT: ret <4 x float> [[ELT_ASIN]]
216 float4
strict_elementwise_asin(float4 a
) {
217 return __builtin_elementwise_asin(a
);
220 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_sinDv4_f
221 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
222 // CHECK-NEXT: entry:
223 // CHECK-NEXT: [[ELT_SIN:%.*]] = tail call <4 x float> @llvm.sin.v4f32(<4 x float> [[A]]) #[[ATTR4]]
224 // CHECK-NEXT: ret <4 x float> [[ELT_SIN]]
226 float4
strict_elementwise_sin(float4 a
) {
227 return __builtin_elementwise_sin(a
);
230 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_sinhDv4_f
231 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
232 // CHECK-NEXT: entry:
233 // CHECK-NEXT: [[ELT_SINH:%.*]] = tail call <4 x float> @llvm.sinh.v4f32(<4 x float> [[A]]) #[[ATTR4]]
234 // CHECK-NEXT: ret <4 x float> [[ELT_SINH]]
236 float4
strict_elementwise_sinh(float4 a
) {
237 return __builtin_elementwise_sinh(a
);
240 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_sqrtDv4_f
241 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0]] {
242 // CHECK-NEXT: entry:
243 // CHECK-NEXT: [[TMP0:%.*]] = tail call <4 x float> @llvm.experimental.constrained.sqrt.v4f32(<4 x float> [[A]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR4]]
244 // CHECK-NEXT: ret <4 x float> [[TMP0]]
246 float4
strict_elementwise_sqrt(float4 a
) {
247 return __builtin_elementwise_sqrt(a
);
250 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_atanDv4_f
251 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
252 // CHECK-NEXT: entry:
253 // CHECK-NEXT: [[ELT_ATAN:%.*]] = tail call <4 x float> @llvm.atan.v4f32(<4 x float> [[A]]) #[[ATTR4]]
254 // CHECK-NEXT: ret <4 x float> [[ELT_ATAN]]
256 float4
strict_elementwise_atan(float4 a
) {
257 return __builtin_elementwise_atan(a
);
260 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_tanDv4_f
261 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
262 // CHECK-NEXT: entry:
263 // CHECK-NEXT: [[ELT_TAN:%.*]] = tail call <4 x float> @llvm.tan.v4f32(<4 x float> [[A]]) #[[ATTR4]]
264 // CHECK-NEXT: ret <4 x float> [[ELT_TAN]]
266 float4
strict_elementwise_tan(float4 a
) {
267 return __builtin_elementwise_tan(a
);
270 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_tanhDv4_f
271 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
272 // CHECK-NEXT: entry:
273 // CHECK-NEXT: [[ELT_TANH:%.*]] = tail call <4 x float> @llvm.tanh.v4f32(<4 x float> [[A]]) #[[ATTR4]]
274 // CHECK-NEXT: ret <4 x float> [[ELT_TANH]]
276 float4
strict_elementwise_tanh(float4 a
) {
277 return __builtin_elementwise_tanh(a
);
280 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z24strict_elementwise_atan2Dv4_fS_
281 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] {
282 // CHECK-NEXT: entry:
283 // CHECK-NEXT: [[ELT_ATAN2:%.*]] = tail call <4 x float> @llvm.atan2.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]]
284 // CHECK-NEXT: ret <4 x float> [[ELT_ATAN2]]
286 float4
strict_elementwise_atan2(float4 a
, float4 b
) {
287 return __builtin_elementwise_atan2(a
, b
);
290 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z24strict_elementwise_truncDv4_f
291 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
292 // CHECK-NEXT: entry:
293 // CHECK-NEXT: [[ELT_TRUNC:%.*]] = tail call <4 x float> @llvm.trunc.v4f32(<4 x float> [[A]]) #[[ATTR4]]
294 // CHECK-NEXT: ret <4 x float> [[ELT_TRUNC]]
296 float4
strict_elementwise_trunc(float4 a
) {
297 return __builtin_elementwise_trunc(a
);
300 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z31strict_elementwise_canonicalizeDv4_f
301 // CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
302 // CHECK-NEXT: entry:
303 // CHECK-NEXT: [[ELT_CANONICALIZE:%.*]] = tail call <4 x float> @llvm.canonicalize.v4f32(<4 x float> [[A]]) #[[ATTR4]]
304 // CHECK-NEXT: ret <4 x float> [[ELT_CANONICALIZE]]
306 float4
strict_elementwise_canonicalize(float4 a
) {
307 return __builtin_elementwise_canonicalize(a
);
310 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z27strict_elementwise_copysignDv4_fS_
311 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] {
312 // CHECK-NEXT: entry:
313 // CHECK-NEXT: [[TMP0:%.*]] = tail call <4 x float> @llvm.copysign.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]]
314 // CHECK-NEXT: ret <4 x float> [[TMP0]]
316 float4
strict_elementwise_copysign(float4 a
, float4 b
) {
317 return __builtin_elementwise_copysign(a
, b
);
320 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_fmaDv4_fS_S_
321 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]], <4 x float> noundef [[C:%.*]]) local_unnamed_addr #[[ATTR2]] {
322 // CHECK-NEXT: entry:
323 // CHECK-NEXT: [[TMP0:%.*]] = tail call <4 x float> @llvm.fma.v4f32(<4 x float> [[A]], <4 x float> [[B]], <4 x float> [[C]]) #[[ATTR4]]
324 // CHECK-NEXT: ret <4 x float> [[TMP0]]
326 float4
strict_elementwise_fma(float4 a
, float4 b
, float4 c
) {
327 return __builtin_elementwise_fma(a
, b
, c
);
330 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_powDv4_fS_
331 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] {
332 // CHECK-NEXT: entry:
333 // CHECK-NEXT: [[TMP0:%.*]] = tail call <4 x float> @llvm.pow.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]]
334 // CHECK-NEXT: ret <4 x float> [[TMP0]]
336 float4
strict_elementwise_pow(float4 a
, float4 b
) {
337 return __builtin_elementwise_pow(a
, b
);
340 // CHECK-LABEL: define dso_local noundef <4 x float> @_Z23strict_elementwise_fmodDv4_fS_
341 // CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR0]] {
342 // CHECK-NEXT: entry:
343 // CHECK-NEXT: [[TMP0:%.*]] = tail call <4 x float> @llvm.experimental.constrained.frem.v4f32(<4 x float> [[A]], <4 x float> [[B]],
344 // CHECK-SAME: metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR4]]
345 // CHECK-NEXT: ret <4 x float> [[TMP0]]
347 float4
strict_elementwise_fmod(float4 a
, float4 b
) {
348 return __builtin_elementwise_fmod(a
, b
);