1 ; RUN: opt -vector-library=LIBMVEC-X86 -passes=inject-tli-mappings,loop-vectorize -S < %s | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 define void @sin_f64(ptr nocapture %varray) {
7 ; CHECK-LABEL: @sin_f64(
8 ; CHECK-LABEL: vector.body
9 ; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_sin(<2 x double> [[TMP4:%.*]])
15 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
16 %tmp = trunc i64 %iv to i32
17 %conv = sitofp i32 %tmp to double
18 %call = tail call double @sin(double %conv)
19 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv
20 store double %call, ptr %arrayidx, align 4
21 %iv.next = add nuw nsw i64 %iv, 1
22 %exitcond = icmp eq i64 %iv.next, 1000
23 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !1
29 !1 = distinct !{!1, !2, !3}
30 !2 = !{!"llvm.loop.vectorize.width", i32 2}
31 !3 = !{!"llvm.loop.vectorize.enable", i1 true}
34 define void @sin_f32(ptr nocapture %varray) {
35 ; CHECK-LABEL: @sin_f32(
36 ; CHECK-LABEL: vector.body
37 ; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_sinf(<8 x float> [[TMP4:%.*]])
43 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
44 %tmp = trunc i64 %iv to i32
45 %conv = sitofp i32 %tmp to float
46 %call = tail call float @sinf(float %conv)
47 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv
48 store float %call, ptr %arrayidx, align 4
49 %iv.next = add nuw nsw i64 %iv, 1
50 %exitcond = icmp eq i64 %iv.next, 1000
51 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !21
57 !21 = distinct !{!21, !22, !23}
58 !22 = !{!"llvm.loop.vectorize.width", i32 8}
59 !23 = !{!"llvm.loop.vectorize.enable", i1 true}
61 define void @sin_f64_intrinsic(ptr nocapture %varray) {
62 ; CHECK-LABEL: @sin_f64_intrinsic(
63 ; CHECK-LABEL: vector.body
64 ; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_sin(<2 x double> [[TMP4:%.*]])
70 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
71 %tmp = trunc i64 %iv to i32
72 %conv = sitofp i32 %tmp to double
73 %call = tail call double @llvm.sin.f64(double %conv)
74 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv
75 store double %call, ptr %arrayidx, align 4
76 %iv.next = add nuw nsw i64 %iv, 1
77 %exitcond = icmp eq i64 %iv.next, 1000
78 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !31
84 !31 = distinct !{!31, !32, !33}
85 !32 = !{!"llvm.loop.vectorize.width", i32 2}
86 !33 = !{!"llvm.loop.vectorize.enable", i1 true}
88 define void @sin_f32_intrinsic(ptr nocapture %varray) {
89 ; CHECK-LABEL: @sin_f32_intrinsic(
90 ; CHECK-LABEL: vector.body
91 ; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_sinf(<8 x float> [[TMP4:%.*]])
97 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
98 %tmp = trunc i64 %iv to i32
99 %conv = sitofp i32 %tmp to float
100 %call = tail call float @llvm.sin.f32(float %conv)
101 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv
102 store float %call, ptr %arrayidx, align 4
103 %iv.next = add nuw nsw i64 %iv, 1
104 %exitcond = icmp eq i64 %iv.next, 1000
105 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !41
111 !41 = distinct !{!41, !42, !43}
112 !42 = !{!"llvm.loop.vectorize.width", i32 8}
113 !43 = !{!"llvm.loop.vectorize.enable", i1 true}
115 define void @cos_f64(ptr nocapture %varray) {
116 ; CHECK-LABEL: @cos_f64(
117 ; CHECK-LABEL: vector.body
118 ; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_cos(<2 x double> [[TMP4:%.*]])
124 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
125 %tmp = trunc i64 %iv to i32
126 %conv = sitofp i32 %tmp to double
127 %call = tail call double @cos(double %conv)
128 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv
129 store double %call, ptr %arrayidx, align 4
130 %iv.next = add nuw nsw i64 %iv, 1
131 %exitcond = icmp eq i64 %iv.next, 1000
132 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !51
138 !51 = distinct !{!51, !52, !53}
139 !52 = !{!"llvm.loop.vectorize.width", i32 2}
140 !53 = !{!"llvm.loop.vectorize.enable", i1 true}
142 define void @cos_f32(ptr nocapture %varray) {
143 ; CHECK-LABEL: @cos_f32(
144 ; CHECK-LABEL: vector.body
145 ; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_cosf(<8 x float> [[TMP4:%.*]])
151 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
152 %tmp = trunc i64 %iv to i32
153 %conv = sitofp i32 %tmp to float
154 %call = tail call float @cosf(float %conv)
155 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv
156 store float %call, ptr %arrayidx, align 4
157 %iv.next = add nuw nsw i64 %iv, 1
158 %exitcond = icmp eq i64 %iv.next, 1000
159 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !61
165 !61 = distinct !{!61, !62, !63}
166 !62 = !{!"llvm.loop.vectorize.width", i32 8}
167 !63 = !{!"llvm.loop.vectorize.enable", i1 true}
169 define void @cos_f64_intrinsic(ptr nocapture %varray) {
170 ; CHECK-LABEL: @cos_f64_intrinsic(
171 ; CHECK-LABEL: vector.body
172 ; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_cos(<2 x double> [[TMP4:%.*]])
178 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
179 %tmp = trunc i64 %iv to i32
180 %conv = sitofp i32 %tmp to double
181 %call = tail call double @llvm.cos.f64(double %conv)
182 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv
183 store double %call, ptr %arrayidx, align 4
184 %iv.next = add nuw nsw i64 %iv, 1
185 %exitcond = icmp eq i64 %iv.next, 1000
186 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !71
192 !71 = distinct !{!71, !72, !73}
193 !72 = !{!"llvm.loop.vectorize.width", i32 2}
194 !73 = !{!"llvm.loop.vectorize.enable", i1 true}
196 define void @cos_f32_intrinsic(ptr nocapture %varray) {
197 ; CHECK-LABEL: @cos_f32_intrinsic(
198 ; CHECK-LABEL: vector.body
199 ; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_cosf(<8 x float> [[TMP4:%.*]])
205 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
206 %tmp = trunc i64 %iv to i32
207 %conv = sitofp i32 %tmp to float
208 %call = tail call float @llvm.cos.f32(float %conv)
209 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv
210 store float %call, ptr %arrayidx, align 4
211 %iv.next = add nuw nsw i64 %iv, 1
212 %exitcond = icmp eq i64 %iv.next, 1000
213 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !81
219 !81 = distinct !{!81, !82, !83}
220 !82 = !{!"llvm.loop.vectorize.width", i32 8}
221 !83 = !{!"llvm.loop.vectorize.enable", i1 true}
224 define void @exp_f32(ptr nocapture %varray) {
225 ; CHECK-LABEL: @exp_f32
226 ; CHECK-LABEL: vector.body
227 ; CHECK: <8 x float> @_ZGVdN8v_expf
231 for.body: ; preds = %for.body, %entry
232 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
233 %tmp = trunc i64 %indvars.iv to i32
234 %conv = sitofp i32 %tmp to float
235 %call = tail call fast float @expf(float %conv)
236 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %indvars.iv
237 store float %call, ptr %arrayidx, align 4
238 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
239 %exitcond = icmp eq i64 %indvars.iv.next, 1000
240 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !91
242 for.end: ; preds = %for.body
246 !91 = distinct !{!91, !92, !93}
247 !92 = !{!"llvm.loop.vectorize.width", i32 8}
248 !93 = !{!"llvm.loop.vectorize.enable", i1 true}
250 define void @exp_f32_intrin(ptr nocapture %varray) {
251 ; CHECK-LABEL: @exp_f32_intrin
252 ; CHECK-LABEL: vector.body
253 ; CHECK: <8 x float> @_ZGVdN8v_expf
257 for.body: ; preds = %for.body, %entry
258 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
259 %tmp = trunc i64 %indvars.iv to i32
260 %conv = sitofp i32 %tmp to float
261 %call = tail call fast float @llvm.exp.f32(float %conv)
262 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %indvars.iv
263 store float %call, ptr %arrayidx, align 4
264 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
265 %exitcond = icmp eq i64 %indvars.iv.next, 1000
266 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !101
268 for.end: ; preds = %for.body
272 !101 = distinct !{!101, !102, !103}
273 !102 = !{!"llvm.loop.vectorize.width", i32 8}
274 !103 = !{!"llvm.loop.vectorize.enable", i1 true}
277 define void @log_f32(ptr nocapture %varray) {
278 ; CHECK-LABEL: @log_f32
279 ; CHECK-LABEL: vector.body
280 ; CHECK: <8 x float> @_ZGVdN8v_logf
284 for.body: ; preds = %for.body, %entry
285 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
286 %tmp = trunc i64 %indvars.iv to i32
287 %conv = sitofp i32 %tmp to float
288 %call = tail call fast float @logf(float %conv)
289 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %indvars.iv
290 store float %call, ptr %arrayidx, align 4
291 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
292 %exitcond = icmp eq i64 %indvars.iv.next, 1000
293 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !111
295 for.end: ; preds = %for.body
299 !111 = distinct !{!111, !112, !113}
300 !112 = !{!"llvm.loop.vectorize.width", i32 8}
301 !113 = !{!"llvm.loop.vectorize.enable", i1 true}
303 define void @pow_f32(ptr nocapture %varray, ptr nocapture readonly %exp) {
304 ; CHECK-LABEL: @pow_f32
305 ; CHECK-LABEL: vector.body
306 ; CHECK: <8 x float> @_ZGVdN8vv_powf
310 for.body: ; preds = %for.body, %entry
311 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
312 %tmp = trunc i64 %indvars.iv to i32
313 %conv = sitofp i32 %tmp to float
314 %arrayidx = getelementptr inbounds float, ptr %exp, i64 %indvars.iv
315 %tmp1 = load float, ptr %arrayidx, align 4
316 %tmp2 = tail call fast float @powf(float %conv, float %tmp1)
317 %arrayidx2 = getelementptr inbounds float, ptr %varray, i64 %indvars.iv
318 store float %tmp2, ptr %arrayidx2, align 4
319 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
320 %exitcond = icmp eq i64 %indvars.iv.next, 1000
321 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !121
323 for.end: ; preds = %for.body
327 !121 = distinct !{!121, !122, !123}
328 !122 = !{!"llvm.loop.vectorize.width", i32 8}
329 !123 = !{!"llvm.loop.vectorize.enable", i1 true}
331 define void @pow_f32_intrin(ptr nocapture %varray, ptr nocapture readonly %exp) {
332 ; CHECK-LABEL: @pow_f32_intrin
333 ; CHECK-LABEL: vector.body
334 ; CHECK: <8 x float> @_ZGVdN8vv_powf
338 for.body: ; preds = %for.body, %entry
339 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
340 %tmp = trunc i64 %indvars.iv to i32
341 %conv = sitofp i32 %tmp to float
342 %arrayidx = getelementptr inbounds float, ptr %exp, i64 %indvars.iv
343 %tmp1 = load float, ptr %arrayidx, align 4
344 %tmp2 = tail call fast float @llvm.pow.f32(float %conv, float %tmp1)
345 %arrayidx2 = getelementptr inbounds float, ptr %varray, i64 %indvars.iv
346 store float %tmp2, ptr %arrayidx2, align 4
347 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
348 %exitcond = icmp eq i64 %indvars.iv.next, 1000
349 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !131
351 for.end: ; preds = %for.body
355 !131 = distinct !{!131, !132, !133}
356 !132 = !{!"llvm.loop.vectorize.width", i32 8}
357 !133 = !{!"llvm.loop.vectorize.enable", i1 true}
359 define void @tan_f64(ptr nocapture %varray) {
360 ; CHECK-LABEL: @tan_f64(
361 ; CHECK-LABEL: vector.body
362 ; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_tan(<2 x double> [[TMP4:%.*]])
368 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
369 %tmp = trunc i64 %iv to i32
370 %conv = sitofp i32 %tmp to double
371 %call = tail call double @tan(double %conv)
372 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv
373 store double %call, ptr %arrayidx, align 4
374 %iv.next = add nuw nsw i64 %iv, 1
375 %exitcond = icmp eq i64 %iv.next, 1000
376 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !1
382 !141 = distinct !{!141, !142, !143}
383 !142 = !{!"llvm.loop.vectorize.width", i32 2}
384 !143 = !{!"llvm.loop.vectorize.enable", i1 true}
387 define void @tan_f32(ptr nocapture %varray) {
388 ; CHECK-LABEL: @tan_f32(
389 ; CHECK-LABEL: vector.body
390 ; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_tanf(<8 x float> [[TMP4:%.*]])
396 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
397 %tmp = trunc i64 %iv to i32
398 %conv = sitofp i32 %tmp to float
399 %call = tail call float @tanf(float %conv)
400 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv
401 store float %call, ptr %arrayidx, align 4
402 %iv.next = add nuw nsw i64 %iv, 1
403 %exitcond = icmp eq i64 %iv.next, 1000
404 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !21
410 !151 = distinct !{!151, !152, !153}
411 !152 = !{!"llvm.loop.vectorize.width", i32 8}
412 !153 = !{!"llvm.loop.vectorize.enable", i1 true}
414 define void @tan_f64_intrinsic(ptr nocapture %varray) {
415 ; CHECK-LABEL: @tan_f64_intrinsic(
416 ; CHECK-LABEL: vector.body
417 ; CHECK: [[TMP5:%.*]] = call <2 x double> @_ZGVbN2v_tan(<2 x double> [[TMP4:%.*]])
423 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
424 %tmp = trunc i64 %iv to i32
425 %conv = sitofp i32 %tmp to double
426 %call = tail call double @llvm.tan.f64(double %conv)
427 %arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv
428 store double %call, ptr %arrayidx, align 4
429 %iv.next = add nuw nsw i64 %iv, 1
430 %exitcond = icmp eq i64 %iv.next, 1000
431 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !31
437 !161 = distinct !{!161, !162, !163}
438 !162 = !{!"llvm.loop.vectorize.width", i32 2}
439 !163 = !{!"llvm.loop.vectorize.enable", i1 true}
441 define void @tan_f32_intrinsic(ptr nocapture %varray) {
442 ; CHECK-LABEL: @tan_f32_intrinsic(
443 ; CHECK-LABEL: vector.body
444 ; CHECK: [[TMP5:%.*]] = call <8 x float> @_ZGVdN8v_tanf(<8 x float> [[TMP4:%.*]])
450 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
451 %tmp = trunc i64 %iv to i32
452 %conv = sitofp i32 %tmp to float
453 %call = tail call float @llvm.tan.f32(float %conv)
454 %arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv
455 store float %call, ptr %arrayidx, align 4
456 %iv.next = add nuw nsw i64 %iv, 1
457 %exitcond = icmp eq i64 %iv.next, 1000
458 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !41
466 !171 = distinct !{!171, !172, !173}
467 !172 = !{!"llvm.loop.vectorize.width", i32 8}
468 !173 = !{!"llvm.loop.vectorize.enable", i1 true}
470 attributes #0 = { nounwind readnone }
472 declare double @sin(double) #0
473 declare float @sinf(float) #0
474 declare double @llvm.sin.f64(double) #0
475 declare float @llvm.sin.f32(float) #0
476 declare double @cos(double) #0
477 declare float @cosf(float) #0
478 declare double @llvm.cos.f64(double) #0
479 declare float @llvm.cos.f32(float) #0
480 declare double @tan(double) #0
481 declare float @tanf(float) #0
482 declare double @llvm.tan.f64(double) #0
483 declare float @llvm.tan.f32(float) #0
484 declare float @expf(float) #0
485 declare float @powf(float, float) #0
486 declare float @llvm.exp.f32(float) #0
487 declare float @logf(float) #0
488 declare float @llvm.pow.f32(float, float) #0