diff --git a/base/math.jl b/base/math.jl index 71bd4949498b5..6b304be7f0ecf 100644 --- a/base/math.jl +++ b/base/math.jl @@ -307,7 +307,7 @@ end Base.@assume_effects :terminates_locally @inline function exthorner(x, p::Tuple) hi, lo = p[end], zero(x) for i in length(p)-1:-1:1 - pi = getfield(p, i) # needed to prove consistency + pi = @inbounds p[i] prod, err = two_mul(hi,x) hi = pi+prod lo = fma(lo, x, prod - (hi - pi) + err) diff --git a/base/special/exp.jl b/base/special/exp.jl index 9cca6f568305f..bbcafce62d5c3 100644 --- a/base/special/exp.jl +++ b/base/special/exp.jl @@ -174,10 +174,9 @@ const J_TABLE = (0x0000000000000000, 0xaac00b1afa5abcbe, 0x9b60163da9fb3335, 0xa 0xa66f0f9c1cb64129, 0x93af252b376bba97, 0xacdf3ac948dd7273, 0x99df50765b6e4540, 0x9faf6632798844f8, 0xa12f7bfdad9cbe13, 0xaeef91d802243c88, 0x874fa7c1819e90d8, 0xacdfbdba3692d513, 0x62efd3c22b8f71f1, 0x74afe9d96b2a23d9) -# :nothrow needed since the compiler can't prove `ind` is inbounds. -Base.@assume_effects :nothrow function table_unpack(ind::Int32) +function table_unpack(ind::Int32) ind = ind & 255 + 1 # 255 == length(J_TABLE) - 1 - j = getfield(J_TABLE, ind) # use getfield so the compiler can prove consistent + j = @inbounds J_TABLE[ind] jU = reinterpret(Float64, JU_CONST | (j&JU_MASK)) jL = reinterpret(Float64, JL_CONST | (j>>8)) return jU, jL diff --git a/base/special/log.jl b/base/special/log.jl index 5d7f1c8118724..cce6a5a90faae 100644 --- a/base/special/log.jl +++ b/base/special/log.jl @@ -155,10 +155,7 @@ logbU(::Type{Float64},::Val{10}) = 0.4342944819032518 logbL(::Type{Float64},::Val{10}) = 1.098319650216765e-17 # Procedure 1 -# XXX we want to mark :consistent-cy here so that this function can be concrete-folded, -# because the effect analysis currently can't prove it in the presence of `@inbounds` or -# `:boundscheck`, but still the access to `t_log_Float64` is really safe here -Base.@assume_effects :consistent @inline function log_proc1(y::Float64,mf::Float64,F::Float64,f::Float64,base=Val(:ℯ)) +@inline function log_proc1(y::Float64,mf::Float64,F::Float64,f::Float64,base=Val(:ℯ)) jp = unsafe_trunc(Int,128.0*F)-127 ## Steps 1 and 2 @@ -216,10 +213,7 @@ end end # Procedure 1 -# XXX we want to mark :consistent-cy here so that this function can be concrete-folded, -# because the effect analysis currently can't prove it in the presence of `@inbounds` or -# `:boundscheck`, but still the access to `t_log_Float32` is really safe here -Base.@assume_effects :consistent @inline function log_proc1(y::Float32,mf::Float32,F::Float32,f::Float32,base=Val(:ℯ)) +@inline function log_proc1(y::Float32,mf::Float32,F::Float32,f::Float32,base=Val(:ℯ)) jp = unsafe_trunc(Int,128.0f0*F)-127 ## Steps 1 and 2 @@ -571,8 +565,7 @@ function _log_ext(xu) z = reinterpret(Float64, xu - (tmp & 0xfff0000000000000)) k = Float64(tmp >> 52) # log(x) = k*Ln2 + log(c) + log1p(z/c-1). - # getfield instead of getindex to satisfy effect analysis not knowing whether this is inbounds - t, logctail = getfield(t_log_table_compact, Int(i+1)) + t, logctail = @inbounds t_log_table_compact[Int(i+1)] invc, logc = log_tab_unpack(t) # Note: invc is j/N or j/N/2 where j is an integer in [N,2N) and # |z/c - 1| < 1/N, so r = z/c - 1 is exactly representable. diff --git a/base/special/rem_pio2.jl b/base/special/rem_pio2.jl index de5c4151df2d0..8ae0dc51bb11f 100644 --- a/base/special/rem_pio2.jl +++ b/base/special/rem_pio2.jl @@ -126,10 +126,7 @@ function fromfraction(f::Int128) return (z1,z2) end -# XXX we want to mark :consistent-cy here so that this function can be concrete-folded, -# because the effect analysis currently can't prove it in the presence of `@inbounds` or -# `:boundscheck`, but still the accesses to `INV_2PI` are really safe here -Base.@assume_effects :consistent function paynehanek(x::Float64) +function paynehanek(x::Float64) # 1. Convert to form # # x = X * 2^k,