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 <4 x double> @_ZGVdN4v_sin(<4 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 4}
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 <4 x float> @_ZGVbN4v_sinf(<4 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 4}
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 <4 x double> @_ZGVdN4v_sin(<4 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 4}
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 <4 x float> @_ZGVbN4v_sinf(<4 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 4}
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 <4 x double> @_ZGVdN4v_cos(<4 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 4}
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 <4 x float> @_ZGVbN4v_cosf(<4 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 4}
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 <4 x double> @_ZGVdN4v_cos(<4 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 4}
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 <4 x float> @_ZGVbN4v_cosf(<4 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 4}
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: <4 x float> @_ZGVbN4v_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 4}
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: <4 x float> @_ZGVbN4v_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 4}
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: <4 x float> @_ZGVbN4v_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 4}
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: <4 x float> @_ZGVbN4vv_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 4}
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: <4 x float> @_ZGVbN4vv_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 4}
357 !133 = !{!"llvm.loop.vectorize.enable", i1 true}
359 attributes #0 = { nounwind readnone }
361 declare double @sin(double) #0
362 declare float @sinf(float) #0
363 declare double @llvm.sin.f64(double) #0
364 declare float @llvm.sin.f32(float) #0
365 declare double @cos(double) #0
366 declare float @cosf(float) #0
367 declare double @llvm.cos.f64(double) #0
368 declare float @llvm.cos.f32(float) #0
369 declare float @expf(float) #0
370 declare float @powf(float, float) #0
371 declare float @llvm.exp.f32(float) #0
372 declare float @logf(float) #0
373 declare float @llvm.pow.f32(float, float) #0