llvm.org GIT mirror llvm / a0e10ad
[TLI] Add mapping for various '__<func>_finite' forms of the math routines to SVML routines Patch by Chris Chrulski Differential Revision: https://reviews.llvm.org/D31789 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302957 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Kaylor 3 years ago
2 changed file(s) with 211 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
13791379 {"powf", "__svml_powf8", 8},
13801380 {"powf", "__svml_powf16", 16},
13811381
1382 { "__pow_finite", "__svml_pow2", 2 },
1383 { "__pow_finite", "__svml_pow4", 4 },
1384 { "__pow_finite", "__svml_pow8", 8 },
1385
1386 { "__powf_finite", "__svml_powf4", 4 },
1387 { "__powf_finite", "__svml_powf8", 8 },
1388 { "__powf_finite", "__svml_powf16", 16 },
1389
13821390 {"llvm.pow.f64", "__svml_pow2", 2},
13831391 {"llvm.pow.f64", "__svml_pow4", 4},
13841392 {"llvm.pow.f64", "__svml_pow8", 8},
13951403 {"expf", "__svml_expf8", 8},
13961404 {"expf", "__svml_expf16", 16},
13971405
1406 { "__exp_finite", "__svml_exp2", 2 },
1407 { "__exp_finite", "__svml_exp4", 4 },
1408 { "__exp_finite", "__svml_exp8", 8 },
1409
1410 { "__expf_finite", "__svml_expf4", 4 },
1411 { "__expf_finite", "__svml_expf8", 8 },
1412 { "__expf_finite", "__svml_expf16", 16 },
1413
13981414 {"llvm.exp.f64", "__svml_exp2", 2},
13991415 {"llvm.exp.f64", "__svml_exp4", 4},
14001416 {"llvm.exp.f64", "__svml_exp8", 8},
14101426 {"logf", "__svml_logf4", 4},
14111427 {"logf", "__svml_logf8", 8},
14121428 {"logf", "__svml_logf16", 16},
1429
1430 { "__log_finite", "__svml_log2", 2 },
1431 { "__log_finite", "__svml_log4", 4 },
1432 { "__log_finite", "__svml_log8", 8 },
1433
1434 { "__logf_finite", "__svml_logf4", 4 },
1435 { "__logf_finite", "__svml_logf8", 8 },
1436 { "__logf_finite", "__svml_logf16", 16 },
14131437
14141438 {"llvm.log.f64", "__svml_log2", 2},
14151439 {"llvm.log.f64", "__svml_log4", 4},
0 ; RUN: opt -vector-library=SVML -loop-vectorize -S < %s | FileCheck %s
1
2 ; Test to verify that when math headers are built with
3 ; __FINITE_MATH_ONLY__ enabled, causing use of ___finite
4 ; function versions, vectorization can map these to vector versions.
5
6 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
8
9 declare float @__expf_finite(float) #0
10
11 ; CHECK-LABEL: @exp_f32
12 ; CHECK: <4 x float> @__svml_expf4
13 ; CHECK: ret
14 define void @exp_f32(float* nocapture %varray) {
15 entry:
16 br label %for.body
17
18 for.body: ; preds = %for.body, %entry
19 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
20 %tmp = trunc i64 %indvars.iv to i32
21 %conv = sitofp i32 %tmp to float
22 %call = tail call fast float @__expf_finite(float %conv)
23 %arrayidx = getelementptr inbounds float, float* %varray, i64 %indvars.iv
24 store float %call, float* %arrayidx, align 4
25 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
26 %exitcond = icmp eq i64 %indvars.iv.next, 1000
27 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !1
28
29 for.end: ; preds = %for.body
30 ret void
31 }
32
33 !1 = distinct !{!1, !2, !3}
34 !2 = !{!"llvm.loop.vectorize.width", i32 4}
35 !3 = !{!"llvm.loop.vectorize.enable", i1 true}
36
37
38 declare double @__exp_finite(double) #0
39
40 ; CHECK-LABEL: @exp_f64
41 ; CHECK: <4 x double> @__svml_exp4
42 ; CHECK: ret
43 define void @exp_f64(double* nocapture %varray) {
44 entry:
45 br label %for.body
46
47 for.body: ; preds = %for.body, %entry
48 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
49 %tmp = trunc i64 %indvars.iv to i32
50 %conv = sitofp i32 %tmp to double
51 %call = tail call fast double @__exp_finite(double %conv)
52 %arrayidx = getelementptr inbounds double, double* %varray, i64 %indvars.iv
53 store double %call, double* %arrayidx, align 4
54 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
55 %exitcond = icmp eq i64 %indvars.iv.next, 1000
56 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !11
57
58 for.end: ; preds = %for.body
59 ret void
60 }
61
62 !11 = distinct !{!11, !12, !13}
63 !12 = !{!"llvm.loop.vectorize.width", i32 4}
64 !13 = !{!"llvm.loop.vectorize.enable", i1 true}
65
66
67
68
69 declare float @__logf_finite(float) #0
70
71 ; CHECK-LABEL: @log_f32
72 ; CHECK: <4 x float> @__svml_logf4
73 ; CHECK: ret
74 define void @log_f32(float* nocapture %varray) {
75 entry:
76 br label %for.body
77
78 for.body: ; preds = %for.body, %entry
79 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
80 %tmp = trunc i64 %indvars.iv to i32
81 %conv = sitofp i32 %tmp to float
82 %call = tail call fast float @__logf_finite(float %conv)
83 %arrayidx = getelementptr inbounds float, float* %varray, i64 %indvars.iv
84 store float %call, float* %arrayidx, align 4
85 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
86 %exitcond = icmp eq i64 %indvars.iv.next, 1000
87 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !21
88
89 for.end: ; preds = %for.body
90 ret void
91 }
92
93 !21 = distinct !{!21, !22, !23}
94 !22 = !{!"llvm.loop.vectorize.width", i32 4}
95 !23 = !{!"llvm.loop.vectorize.enable", i1 true}
96
97
98 declare double @__log_finite(double) #0
99
100 ; CHECK-LABEL: @log_f64
101 ; CHECK: <4 x double> @__svml_log4
102 ; CHECK: ret
103 define void @log_f64(double* nocapture %varray) {
104 entry:
105 br label %for.body
106
107 for.body: ; preds = %for.body, %entry
108 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
109 %tmp = trunc i64 %indvars.iv to i32
110 %conv = sitofp i32 %tmp to double
111 %call = tail call fast double @__log_finite(double %conv)
112 %arrayidx = getelementptr inbounds double, double* %varray, i64 %indvars.iv
113 store double %call, double* %arrayidx, align 4
114 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
115 %exitcond = icmp eq i64 %indvars.iv.next, 1000
116 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !31
117
118 for.end: ; preds = %for.body
119 ret void
120 }
121
122 !31 = distinct !{!31, !32, !33}
123 !32 = !{!"llvm.loop.vectorize.width", i32 4}
124 !33 = !{!"llvm.loop.vectorize.enable", i1 true}
125
126
127 declare float @__powf_finite(float, float) #0
128
129 ; CHECK-LABEL: @pow_f32
130 ; CHECK: <4 x float> @__svml_powf4
131 ; CHECK: ret
132 define void @pow_f32(float* nocapture %varray, float* nocapture readonly %exp) {
133 entry:
134 br label %for.body
135
136 for.body: ; preds = %for.body, %entry
137 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
138 %tmp = trunc i64 %indvars.iv to i32
139 %conv = sitofp i32 %tmp to float
140 %arrayidx = getelementptr inbounds float, float* %exp, i64 %indvars.iv
141 %tmp1 = load float, float* %arrayidx, align 4
142 %tmp2 = tail call fast float @__powf_finite(float %conv, float %tmp1)
143 %arrayidx2 = getelementptr inbounds float, float* %varray, i64 %indvars.iv
144 store float %tmp2, float* %arrayidx2, align 4
145 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
146 %exitcond = icmp eq i64 %indvars.iv.next, 1000
147 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !41
148
149 for.end: ; preds = %for.body
150 ret void
151 }
152
153 !41 = distinct !{!41, !42, !43}
154 !42 = !{!"llvm.loop.vectorize.width", i32 4}
155 !43 = !{!"llvm.loop.vectorize.enable", i1 true}
156
157
158 declare double @__pow_finite(double, double) #0
159
160 ; CHECK-LABEL: @pow_f64
161 ; CHECK: <4 x double> @__svml_pow4
162 ; CHECK: ret
163 define void @pow_f64(double* nocapture %varray, double* nocapture readonly %exp) {
164 entry:
165 br label %for.body
166
167 for.body: ; preds = %for.body, %entry
168 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
169 %tmp = trunc i64 %indvars.iv to i32
170 %conv = sitofp i32 %tmp to double
171 %arrayidx = getelementptr inbounds double, double* %exp, i64 %indvars.iv
172 %tmp1 = load double, double* %arrayidx, align 4
173 %tmp2 = tail call fast double @__pow_finite(double %conv, double %tmp1)
174 %arrayidx2 = getelementptr inbounds double, double* %varray, i64 %indvars.iv
175 store double %tmp2, double* %arrayidx2, align 4
176 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
177 %exitcond = icmp eq i64 %indvars.iv.next, 1000
178 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !51
179
180 for.end: ; preds = %for.body
181 ret void
182 }
183
184 !51 = distinct !{!51, !52, !53}
185 !52 = !{!"llvm.loop.vectorize.width", i32 4}
186 !53 = !{!"llvm.loop.vectorize.enable", i1 true}