Skip to content

Commit 87fbfb1

Browse files
oscardssmithKristofferC
authored andcommitted
@noinline exp by default. (#46359)
also remove a bunch of `@inline` from when I didn't trust the compiler to do reasonable things. (cherry picked from commit 445586d)
1 parent 3d7ddf8 commit 87fbfb1

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

base/special/exp.jl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,30 @@ LogB(::Val{:ℯ}, ::Type{Float16}) = -0.6931472f0
7070
LogB(::Val{10}, ::Type{Float16}) = -0.30103f0
7171

7272
# Range reduced kernels
73-
@inline function expm1b_kernel(::Val{2}, x::Float64)
73+
function expm1b_kernel(::Val{2}, x::Float64)
7474
return x * evalpoly(x, (0.6931471805599393, 0.24022650695910058,
7575
0.05550411502333161, 0.009618129548366803))
7676
end
77-
@inline function expm1b_kernel(::Val{:ℯ}, x::Float64)
77+
function expm1b_kernel(::Val{:ℯ}, x::Float64)
7878
return x * evalpoly(x, (0.9999999999999912, 0.4999999999999997,
7979
0.1666666857598779, 0.04166666857598777))
8080
end
81-
82-
@inline function expm1b_kernel(::Val{10}, x::Float64)
81+
function expm1b_kernel(::Val{10}, x::Float64)
8382
return x * evalpoly(x, (2.3025850929940255, 2.6509490552391974,
8483
2.034678825384765, 1.1712552025835192))
8584
end
8685

87-
@inline function expb_kernel(::Val{2}, x::Float32)
86+
function expb_kernel(::Val{2}, x::Float32)
8887
return evalpoly(x, (1.0f0, 0.6931472f0, 0.2402265f0,
8988
0.05550411f0, 0.009618025f0,
9089
0.0013333423f0, 0.00015469732f0, 1.5316464f-5))
9190
end
92-
@inline function expb_kernel(::Val{:ℯ}, x::Float32)
91+
function expb_kernel(::Val{:ℯ}, x::Float32)
9392
return evalpoly(x, (1.0f0, 1.0f0, 0.5f0, 0.16666667f0,
9493
0.041666217f0, 0.008333249f0,
9594
0.001394858f0, 0.00019924171f0))
9695
end
97-
@inline function expb_kernel(::Val{10}, x::Float32)
96+
function expb_kernel(::Val{10}, x::Float32)
9897
return evalpoly(x, (1.0f0, 2.3025851f0, 2.650949f0,
9998
2.0346787f0, 1.1712426f0, 0.53937745f0,
10099
0.20788547f0, 0.06837386f0))
@@ -178,7 +177,7 @@ const J_TABLE = (0x0000000000000000, 0xaac00b1afa5abcbe, 0x9b60163da9fb3335, 0xa
178177
# XXX we want to mark :consistent-cy here so that this function can be concrete-folded,
179178
# because the effect analysis currently can't prove it in the presence of `@inbounds` or
180179
# `:boundscheck`, but still the access to `J_TABLE` is really safe here
181-
Base.@assume_effects :consistent @inline function table_unpack(ind::Int32)
180+
@noinline Base.@assume_effects :consistent @inline function table_unpack(ind::Int32)
182181
ind = ind & 255 + 1 # 255 == length(J_TABLE) - 1
183182
j = @inbounds J_TABLE[ind]
184183
jU = reinterpret(Float64, JU_CONST | (j&JU_MASK))
@@ -224,7 +223,7 @@ end
224223
if k <= -53
225224
# The UInt64 forces promotion. (Only matters for 32 bit systems.)
226225
twopk = (k + UInt64(53)) << 52
227-
return reinterpret(T, twopk + reinterpret(UInt64, small_part))*(2.0^-53)
226+
return reinterpret(T, twopk + reinterpret(UInt64, small_part))*0x1p-53
228227
end
229228
#k == 1024 && return (small_part * 2.0) * 2.0^1023
230229
end
@@ -249,7 +248,7 @@ end
249248
if k <= -53
250249
# The UInt64 forces promotion. (Only matters for 32 bit systems.)
251250
twopk = (k + UInt64(53)) << 52
252-
return reinterpret(T, twopk + reinterpret(UInt64, small_part))*(2.0^-53)
251+
return reinterpret(T, twopk + reinterpret(UInt64, small_part))*0x1p-53
253252
end
254253
#k == 1024 && return (small_part * 2.0) * 2.0^1023
255254
end
@@ -324,8 +323,8 @@ for (func, fast_func, base) in ((:exp2, :exp2_fast, Val(2)),
324323
(:exp, :exp_fast, Val(:ℯ)),
325324
(:exp10, :exp10_fast, Val(10)))
326325
@eval begin
327-
$func(x::Union{Float16,Float32,Float64}) = exp_impl(x, $base)
328-
$fast_func(x::Union{Float32,Float64}) = exp_impl_fast(x, $base)
326+
@noinline $func(x::Union{Float16,Float32,Float64}) = exp_impl(x, $base)
327+
@noinline $fast_func(x::Union{Float32,Float64}) = exp_impl_fast(x, $base)
329328
end
330329
end
331330

0 commit comments

Comments
 (0)