[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / test / Transforms / LoopVectorize / X86 / svml-calls.ll
blob8ff62f178d09faf481cc2cc6b379ae81d15972d4
1 ; RUN: opt -vector-library=SVML -loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -mattr=avx -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 declare double @sin(double) #0
7 declare float @sinf(float) #0
8 declare double @llvm.sin.f64(double) #0
9 declare float @llvm.sin.f32(float) #0
11 declare double @cos(double) #0
12 declare float @cosf(float) #0
13 declare double @llvm.cos.f64(double) #0
14 declare float @llvm.cos.f32(float) #0
16 declare double @pow(double, double) #0
17 declare float @powf(float, float) #0
18 declare double @llvm.pow.f64(double, double) #0
19 declare float @llvm.pow.f32(float, float) #0
21 declare double @exp(double) #0
22 declare float @expf(float) #0
23 declare double @llvm.exp.f64(double) #0
24 declare float @llvm.exp.f32(float) #0
26 declare double @log(double) #0
27 declare float @logf(float) #0
28 declare double @llvm.log.f64(double) #0
29 declare float @llvm.log.f32(float) #0
32 define void @sin_f64(double* nocapture %varray) {
33 ; CHECK-LABEL: @sin_f64(
34 ; CHECK:    [[TMP5:%.*]] = call <4 x double> @__svml_sin4(<4 x double> [[TMP4:%.*]])
35 ; CHECK:    ret void
37 entry:
38   br label %for.body
40 for.body:
41   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
42   %tmp = trunc i64 %iv to i32
43   %conv = sitofp i32 %tmp to double
44   %call = tail call double @sin(double %conv)
45   %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
46   store double %call, double* %arrayidx, align 4
47   %iv.next = add nuw nsw i64 %iv, 1
48   %exitcond = icmp eq i64 %iv.next, 1000
49   br i1 %exitcond, label %for.end, label %for.body
51 for.end:
52   ret void
55 define void @sin_f32(float* nocapture %varray) {
56 ; CHECK-LABEL: @sin_f32(
57 ; CHECK:    [[TMP5:%.*]] = call <4 x float> @__svml_sinf4(<4 x float> [[TMP4:%.*]])
58 ; CHECK:    ret void
60 entry:
61   br label %for.body
63 for.body:
64   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
65   %tmp = trunc i64 %iv to i32
66   %conv = sitofp i32 %tmp to float
67   %call = tail call float @sinf(float %conv)
68   %arrayidx = getelementptr inbounds float, float* %varray, i64 %iv
69   store float %call, float* %arrayidx, align 4
70   %iv.next = add nuw nsw i64 %iv, 1
71   %exitcond = icmp eq i64 %iv.next, 1000
72   br i1 %exitcond, label %for.end, label %for.body
74 for.end:
75   ret void
78 define void @sin_f64_intrinsic(double* nocapture %varray) {
79 ; CHECK-LABEL: @sin_f64_intrinsic(
80 ; CHECK:    [[TMP5:%.*]] = call <4 x double> @__svml_sin4(<4 x double> [[TMP4:%.*]])
81 ; CHECK:    ret void
83 entry:
84   br label %for.body
86 for.body:
87   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
88   %tmp = trunc i64 %iv to i32
89   %conv = sitofp i32 %tmp to double
90   %call = tail call double @llvm.sin.f64(double %conv)
91   %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
92   store double %call, double* %arrayidx, align 4
93   %iv.next = add nuw nsw i64 %iv, 1
94   %exitcond = icmp eq i64 %iv.next, 1000
95   br i1 %exitcond, label %for.end, label %for.body
97 for.end:
98   ret void
101 define void @sin_f32_intrinsic(float* nocapture %varray) {
102 ; CHECK-LABEL: @sin_f32_intrinsic(
103 ; CHECK:    [[TMP5:%.*]] = call <4 x float> @__svml_sinf4(<4 x float> [[TMP4:%.*]])
104 ; CHECK:    ret void
106 entry:
107   br label %for.body
109 for.body:
110   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
111   %tmp = trunc i64 %iv to i32
112   %conv = sitofp i32 %tmp to float
113   %call = tail call float @llvm.sin.f32(float %conv)
114   %arrayidx = getelementptr inbounds float, float* %varray, i64 %iv
115   store float %call, float* %arrayidx, align 4
116   %iv.next = add nuw nsw i64 %iv, 1
117   %exitcond = icmp eq i64 %iv.next, 1000
118   br i1 %exitcond, label %for.end, label %for.body
120 for.end:
121   ret void
124 define void @cos_f64(double* nocapture %varray) {
125 ; CHECK-LABEL: @cos_f64(
126 ; CHECK:    [[TMP5:%.*]] = call <4 x double> @__svml_cos4(<4 x double> [[TMP4:%.*]])
127 ; CHECK:    ret void
129 entry:
130   br label %for.body
132 for.body:
133   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
134   %tmp = trunc i64 %iv to i32
135   %conv = sitofp i32 %tmp to double
136   %call = tail call double @cos(double %conv)
137   %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
138   store double %call, double* %arrayidx, align 4
139   %iv.next = add nuw nsw i64 %iv, 1
140   %exitcond = icmp eq i64 %iv.next, 1000
141   br i1 %exitcond, label %for.end, label %for.body
143 for.end:
144   ret void
147 define void @cos_f32(float* nocapture %varray) {
148 ; CHECK-LABEL: @cos_f32(
149 ; CHECK:    [[TMP5:%.*]] = call <4 x float> @__svml_cosf4(<4 x float> [[TMP4:%.*]])
150 ; CHECK:    ret void
152 entry:
153   br label %for.body
155 for.body:
156   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
157   %tmp = trunc i64 %iv to i32
158   %conv = sitofp i32 %tmp to float
159   %call = tail call float @cosf(float %conv)
160   %arrayidx = getelementptr inbounds float, float* %varray, i64 %iv
161   store float %call, float* %arrayidx, align 4
162   %iv.next = add nuw nsw i64 %iv, 1
163   %exitcond = icmp eq i64 %iv.next, 1000
164   br i1 %exitcond, label %for.end, label %for.body
166 for.end:
167   ret void
170 define void @cos_f64_intrinsic(double* nocapture %varray) {
171 ; CHECK-LABEL: @cos_f64_intrinsic(
172 ; CHECK:    [[TMP5:%.*]] = call <4 x double> @__svml_cos4(<4 x double> [[TMP4:%.*]])
173 ; CHECK:    ret void
175 entry:
176   br label %for.body
178 for.body:
179   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
180   %tmp = trunc i64 %iv to i32
181   %conv = sitofp i32 %tmp to double
182   %call = tail call double @llvm.cos.f64(double %conv)
183   %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
184   store double %call, double* %arrayidx, align 4
185   %iv.next = add nuw nsw i64 %iv, 1
186   %exitcond = icmp eq i64 %iv.next, 1000
187   br i1 %exitcond, label %for.end, label %for.body
189 for.end:
190   ret void
193 define void @cos_f32_intrinsic(float* nocapture %varray) {
194 ; CHECK-LABEL: @cos_f32_intrinsic(
195 ; CHECK:    [[TMP5:%.*]] = call <4 x float> @__svml_cosf4(<4 x float> [[TMP4:%.*]])
196 ; CHECK:    ret void
198 entry:
199   br label %for.body
201 for.body:
202   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
203   %tmp = trunc i64 %iv to i32
204   %conv = sitofp i32 %tmp to float
205   %call = tail call float @llvm.cos.f32(float %conv)
206   %arrayidx = getelementptr inbounds float, float* %varray, i64 %iv
207   store float %call, float* %arrayidx, align 4
208   %iv.next = add nuw nsw i64 %iv, 1
209   %exitcond = icmp eq i64 %iv.next, 1000
210   br i1 %exitcond, label %for.end, label %for.body
212 for.end:
213   ret void
216 define void @pow_f64(double* nocapture %varray, double* nocapture readonly %exp) {
217 ; CHECK-LABEL: @pow_f64(
218 ; CHECK:    [[TMP8:%.*]] = call <4 x double> @__svml_pow4(<4 x double> [[TMP4:%.*]], <4 x double> [[WIDE_LOAD:%.*]])
219 ; CHECK:    ret void
221 entry:
222   br label %for.body
224 for.body:
225   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
226   %tmp = trunc i64 %iv to i32
227   %conv = sitofp i32 %tmp to double
228   %arrayidx = getelementptr inbounds double, double* %exp, i64 %iv
229   %tmp1 = load double, double* %arrayidx, align 4
230   %tmp2 = tail call double @pow(double %conv, double %tmp1)
231   %arrayidx2 = getelementptr inbounds double, double* %varray, i64 %iv
232   store double %tmp2, double* %arrayidx2, align 4
233   %iv.next = add nuw nsw i64 %iv, 1
234   %exitcond = icmp eq i64 %iv.next, 1000
235   br i1 %exitcond, label %for.end, label %for.body
237 for.end:
238   ret void
241 define void @pow_f64_intrinsic(double* nocapture %varray, double* nocapture readonly %exp) {
242 ; CHECK-LABEL: @pow_f64_intrinsic(
243 ; CHECK:    [[TMP8:%.*]] = call <4 x double> @__svml_pow4(<4 x double> [[TMP4:%.*]], <4 x double> [[WIDE_LOAD:%.*]])
244 ; CHECK:    ret void
246 entry:
247   br label %for.body
249 for.body:
250   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
251   %tmp = trunc i64 %iv to i32
252   %conv = sitofp i32 %tmp to double
253   %arrayidx = getelementptr inbounds double, double* %exp, i64 %iv
254   %tmp1 = load double, double* %arrayidx, align 4
255   %tmp2 = tail call double @llvm.pow.f64(double %conv, double %tmp1)
256   %arrayidx2 = getelementptr inbounds double, double* %varray, i64 %iv
257   store double %tmp2, double* %arrayidx2, align 4
258   %iv.next = add nuw nsw i64 %iv, 1
259   %exitcond = icmp eq i64 %iv.next, 1000
260   br i1 %exitcond, label %for.end, label %for.body
262 for.end:
263   ret void
266 define void @pow_f32(float* nocapture %varray, float* nocapture readonly %exp) {
267 ; CHECK-LABEL: @pow_f32(
268 ; CHECK:    [[TMP8:%.*]] = call <4 x float> @__svml_powf4(<4 x float> [[TMP4:%.*]], <4 x float> [[WIDE_LOAD:%.*]])
269 ; CHECK:    ret void
271 entry:
272   br label %for.body
274 for.body:
275   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
276   %tmp = trunc i64 %iv to i32
277   %conv = sitofp i32 %tmp to float
278   %arrayidx = getelementptr inbounds float, float* %exp, i64 %iv
279   %tmp1 = load float, float* %arrayidx, align 4
280   %tmp2 = tail call float @powf(float %conv, float %tmp1)
281   %arrayidx2 = getelementptr inbounds float, float* %varray, i64 %iv
282   store float %tmp2, float* %arrayidx2, align 4
283   %iv.next = add nuw nsw i64 %iv, 1
284   %exitcond = icmp eq i64 %iv.next, 1000
285   br i1 %exitcond, label %for.end, label %for.body
287 for.end:
288   ret void
291 define void @pow_f32_intrinsic(float* nocapture %varray, float* nocapture readonly %exp) {
292 ; CHECK-LABEL: @pow_f32_intrinsic(
293 ; CHECK:    [[TMP8:%.*]] = call <4 x float> @__svml_powf4(<4 x float> [[TMP4:%.*]], <4 x float> [[WIDE_LOAD:%.*]])
294 ; CHECK:    ret void
296 entry:
297   br label %for.body
299 for.body:
300   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
301   %tmp = trunc i64 %iv to i32
302   %conv = sitofp i32 %tmp to float
303   %arrayidx = getelementptr inbounds float, float* %exp, i64 %iv
304   %tmp1 = load float, float* %arrayidx, align 4
305   %tmp2 = tail call float @llvm.pow.f32(float %conv, float %tmp1)
306   %arrayidx2 = getelementptr inbounds float, float* %varray, i64 %iv
307   store float %tmp2, float* %arrayidx2, align 4
308   %iv.next = add nuw nsw i64 %iv, 1
309   %exitcond = icmp eq i64 %iv.next, 1000
310   br i1 %exitcond, label %for.end, label %for.body
312 for.end:
313   ret void
316 define void @exp_f64(double* nocapture %varray) {
317 ; CHECK-LABEL: @exp_f64(
318 ; CHECK:    [[TMP5:%.*]] = call <4 x double> @__svml_exp4(<4 x double> [[TMP4:%.*]])
319 ; CHECK:    ret void
321 entry:
322   br label %for.body
324 for.body:
325   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
326   %tmp = trunc i64 %iv to i32
327   %conv = sitofp i32 %tmp to double
328   %call = tail call double @exp(double %conv)
329   %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
330   store double %call, double* %arrayidx, align 4
331   %iv.next = add nuw nsw i64 %iv, 1
332   %exitcond = icmp eq i64 %iv.next, 1000
333   br i1 %exitcond, label %for.end, label %for.body
335 for.end:
336   ret void
339 define void @exp_f32(float* nocapture %varray) {
340 ; CHECK-LABEL: @exp_f32(
341 ; CHECK:    [[TMP5:%.*]] = call <4 x float> @__svml_expf4(<4 x float> [[TMP4:%.*]])
342 ; CHECK:    ret void
344 entry:
345   br label %for.body
347 for.body:
348   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
349   %tmp = trunc i64 %iv to i32
350   %conv = sitofp i32 %tmp to float
351   %call = tail call float @expf(float %conv)
352   %arrayidx = getelementptr inbounds float, float* %varray, i64 %iv
353   store float %call, float* %arrayidx, align 4
354   %iv.next = add nuw nsw i64 %iv, 1
355   %exitcond = icmp eq i64 %iv.next, 1000
356   br i1 %exitcond, label %for.end, label %for.body
358 for.end:
359   ret void
362 define void @exp_f64_intrinsic(double* nocapture %varray) {
363 ; CHECK-LABEL: @exp_f64_intrinsic(
364 ; CHECK:    [[TMP5:%.*]] = call <4 x double> @__svml_exp4(<4 x double> [[TMP4:%.*]])
365 ; CHECK:    ret void
367 entry:
368   br label %for.body
370 for.body:
371   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
372   %tmp = trunc i64 %iv to i32
373   %conv = sitofp i32 %tmp to double
374   %call = tail call double @llvm.exp.f64(double %conv)
375   %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
376   store double %call, double* %arrayidx, align 4
377   %iv.next = add nuw nsw i64 %iv, 1
378   %exitcond = icmp eq i64 %iv.next, 1000
379   br i1 %exitcond, label %for.end, label %for.body
381 for.end:
382   ret void
385 define void @exp_f32_intrinsic(float* nocapture %varray) {
386 ; CHECK-LABEL: @exp_f32_intrinsic(
387 ; CHECK:    [[TMP5:%.*]] = call <4 x float> @__svml_expf4(<4 x float> [[TMP4:%.*]])
388 ; CHECK:    ret void
390 entry:
391   br label %for.body
393 for.body:
394   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
395   %tmp = trunc i64 %iv to i32
396   %conv = sitofp i32 %tmp to float
397   %call = tail call float @llvm.exp.f32(float %conv)
398   %arrayidx = getelementptr inbounds float, float* %varray, i64 %iv
399   store float %call, float* %arrayidx, align 4
400   %iv.next = add nuw nsw i64 %iv, 1
401   %exitcond = icmp eq i64 %iv.next, 1000
402   br i1 %exitcond, label %for.end, label %for.body
404 for.end:
405   ret void
408 define void @log_f64(double* nocapture %varray) {
409 ; CHECK-LABEL: @log_f64(
410 ; CHECK:    [[TMP5:%.*]] = call <4 x double> @__svml_log4(<4 x double> [[TMP4:%.*]])
411 ; CHECK:    ret void
413 entry:
414   br label %for.body
416 for.body:
417   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
418   %tmp = trunc i64 %iv to i32
419   %conv = sitofp i32 %tmp to double
420   %call = tail call double @log(double %conv)
421   %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
422   store double %call, double* %arrayidx, align 4
423   %iv.next = add nuw nsw i64 %iv, 1
424   %exitcond = icmp eq i64 %iv.next, 1000
425   br i1 %exitcond, label %for.end, label %for.body
427 for.end:
428   ret void
431 define void @log_f32(float* nocapture %varray) {
432 ; CHECK-LABEL: @log_f32(
433 ; CHECK:    [[TMP5:%.*]] = call <4 x float> @__svml_logf4(<4 x float> [[TMP4:%.*]])
434 ; CHECK:    ret void
436 entry:
437   br label %for.body
439 for.body:
440   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
441   %tmp = trunc i64 %iv to i32
442   %conv = sitofp i32 %tmp to float
443   %call = tail call float @logf(float %conv)
444   %arrayidx = getelementptr inbounds float, float* %varray, i64 %iv
445   store float %call, float* %arrayidx, align 4
446   %iv.next = add nuw nsw i64 %iv, 1
447   %exitcond = icmp eq i64 %iv.next, 1000
448   br i1 %exitcond, label %for.end, label %for.body
450 for.end:
451   ret void
454 define void @log_f64_intrinsic(double* nocapture %varray) {
455 ; CHECK-LABEL: @log_f64_intrinsic(
456 ; CHECK:    [[TMP5:%.*]] = call <4 x double> @__svml_log4(<4 x double> [[TMP4:%.*]])
457 ; CHECK:    ret void
459 entry:
460   br label %for.body
462 for.body:
463   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
464   %tmp = trunc i64 %iv to i32
465   %conv = sitofp i32 %tmp to double
466   %call = tail call double @llvm.log.f64(double %conv)
467   %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
468   store double %call, double* %arrayidx, align 4
469   %iv.next = add nuw nsw i64 %iv, 1
470   %exitcond = icmp eq i64 %iv.next, 1000
471   br i1 %exitcond, label %for.end, label %for.body
473 for.end:
474   ret void
477 define void @log_f32_intrinsic(float* nocapture %varray) {
478 ; CHECK-LABEL: @log_f32_intrinsic(
479 ; CHECK:    [[TMP5:%.*]] = call <4 x float> @__svml_logf4(<4 x float> [[TMP4:%.*]])
480 ; CHECK:    ret void
482 entry:
483   br label %for.body
485 for.body:
486   %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
487   %tmp = trunc i64 %iv to i32
488   %conv = sitofp i32 %tmp to float
489   %call = tail call float @llvm.log.f32(float %conv)
490   %arrayidx = getelementptr inbounds float, float* %varray, i64 %iv
491   store float %call, float* %arrayidx, align 4
492   %iv.next = add nuw nsw i64 %iv, 1
493   %exitcond = icmp eq i64 %iv.next, 1000
494   br i1 %exitcond, label %for.end, label %for.body
496 for.end:
497   ret void
500 attributes #0 = { nounwind readnone }