1; RUN: opt -vector-library=SVML -loop-vectorize -S < %s | FileCheck %s
2
3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6; CHECK-LABEL: @sin_f32
7; CHECK: <4 x float> @__svml_sinf4
8; CHECK: ret
9
10declare float @sinf(float) #0
11
12define void @sin_f32(float* nocapture %varray) {
13entry:
14  br label %for.body
15
16for.body:                                         ; preds = %for.body, %entry
17  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
18  %tmp = trunc i64 %indvars.iv to i32
19  %conv = sitofp i32 %tmp to float
20  %call = tail call fast float @sinf(float %conv)
21  %arrayidx = getelementptr inbounds float, float* %varray, i64 %indvars.iv
22  store float %call, float* %arrayidx, align 4
23  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
24  %exitcond = icmp eq i64 %indvars.iv.next, 1000
25  br i1 %exitcond, label %for.end, label %for.body
26
27for.end:                                          ; preds = %for.body
28  ret void
29}
30
31; CHECK-LABEL: @cos_f32
32; CHECK: <4 x float> @__svml_cosf4
33; CHECK: ret
34
35declare float @cosf(float) #0
36
37define void @cos_f32(float* nocapture %varray) {
38entry:
39  br label %for.body
40
41for.body:                                         ; preds = %for.body, %entry
42  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
43  %tmp = trunc i64 %indvars.iv to i32
44  %conv = sitofp i32 %tmp to float
45  %call = tail call fast float @cosf(float %conv)
46  %arrayidx = getelementptr inbounds float, float* %varray, i64 %indvars.iv
47  store float %call, float* %arrayidx, align 4
48  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
49  %exitcond = icmp eq i64 %indvars.iv.next, 1000
50  br i1 %exitcond, label %for.end, label %for.body
51
52for.end:                                          ; preds = %for.body
53  ret void
54}
55
56; CHECK-LABEL: @exp_f32
57; CHECK: <4 x float> @__svml_expf4
58; CHECK: ret
59
60declare float @expf(float) #0
61
62define void @exp_f32(float* nocapture %varray) {
63entry:
64  br label %for.body
65
66for.body:                                         ; preds = %for.body, %entry
67  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
68  %tmp = trunc i64 %indvars.iv to i32
69  %conv = sitofp i32 %tmp to float
70  %call = tail call fast float @expf(float %conv)
71  %arrayidx = getelementptr inbounds float, float* %varray, i64 %indvars.iv
72  store float %call, float* %arrayidx, align 4
73  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
74  %exitcond = icmp eq i64 %indvars.iv.next, 1000
75  br i1 %exitcond, label %for.end, label %for.body
76
77for.end:                                          ; preds = %for.body
78  ret void
79}
80
81; CHECK-LABEL: @exp_f32_intrin
82; CHECK: <4 x float> @__svml_expf4
83; CHECK: ret
84
85declare float @llvm.exp.f32(float) #0
86
87define void @exp_f32_intrin(float* nocapture %varray) {
88entry:
89  br label %for.body
90
91for.body:                                         ; preds = %for.body, %entry
92  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
93  %tmp = trunc i64 %indvars.iv to i32
94  %conv = sitofp i32 %tmp to float
95  %call = tail call fast float @llvm.exp.f32(float %conv)
96  %arrayidx = getelementptr inbounds float, float* %varray, i64 %indvars.iv
97  store float %call, float* %arrayidx, align 4
98  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
99  %exitcond = icmp eq i64 %indvars.iv.next, 1000
100  br i1 %exitcond, label %for.end, label %for.body
101
102for.end:                                          ; preds = %for.body
103  ret void
104}
105
106; CHECK-LABEL: @log_f32
107; CHECK: <4 x float> @__svml_logf4
108; CHECK: ret
109
110declare float @logf(float) #0
111
112define void @log_f32(float* nocapture %varray) {
113entry:
114  br label %for.body
115
116for.body:                                         ; preds = %for.body, %entry
117  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
118  %tmp = trunc i64 %indvars.iv to i32
119  %conv = sitofp i32 %tmp to float
120  %call = tail call fast float @logf(float %conv)
121  %arrayidx = getelementptr inbounds float, float* %varray, i64 %indvars.iv
122  store float %call, float* %arrayidx, align 4
123  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
124  %exitcond = icmp eq i64 %indvars.iv.next, 1000
125  br i1 %exitcond, label %for.end, label %for.body
126
127for.end:                                          ; preds = %for.body
128  ret void
129}
130
131; CHECK-LABEL: @pow_f32
132; CHECK: <4 x float> @__svml_powf4
133; CHECK: ret
134
135declare float @powf(float, float) #0
136
137define void @pow_f32(float* nocapture %varray, float* nocapture readonly %exp) {
138entry:
139  br label %for.body
140
141for.body:                                         ; preds = %for.body, %entry
142  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
143  %tmp = trunc i64 %indvars.iv to i32
144  %conv = sitofp i32 %tmp to float
145  %arrayidx = getelementptr inbounds float, float* %exp, i64 %indvars.iv
146  %tmp1 = load float, float* %arrayidx, align 4
147  %tmp2 = tail call fast float @powf(float %conv, float %tmp1)
148  %arrayidx2 = getelementptr inbounds float, float* %varray, i64 %indvars.iv
149  store float %tmp2, float* %arrayidx2, align 4
150  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
151  %exitcond = icmp eq i64 %indvars.iv.next, 1000
152  br i1 %exitcond, label %for.end, label %for.body
153
154for.end:                                          ; preds = %for.body
155  ret void
156}
157
158; CHECK-LABEL: @pow_f32_intrin
159; CHECK: <4 x float> @__svml_powf4
160; CHECK: ret
161
162declare float @llvm.pow.f32(float, float) #0
163
164define void @pow_f32_intrin(float* nocapture %varray, float* nocapture readonly %exp) {
165entry:
166  br label %for.body
167
168for.body:                                         ; preds = %for.body, %entry
169  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
170  %tmp = trunc i64 %indvars.iv to i32
171  %conv = sitofp i32 %tmp to float
172  %arrayidx = getelementptr inbounds float, float* %exp, i64 %indvars.iv
173  %tmp1 = load float, float* %arrayidx, align 4
174  %tmp2 = tail call fast float @llvm.pow.f32(float %conv, float %tmp1)
175  %arrayidx2 = getelementptr inbounds float, float* %varray, i64 %indvars.iv
176  store float %tmp2, float* %arrayidx2, align 4
177  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
178  %exitcond = icmp eq i64 %indvars.iv.next, 1000
179  br i1 %exitcond, label %for.end, label %for.body
180
181for.end:                                          ; preds = %for.body
182  ret void
183}
184
185attributes #0 = { nounwind readnone }
186