@@ -6,8 +6,8 @@ const libm = OpenLibm_jll.libopenlibm
66for f in (:sin , :cos , :tan , :asin , :acos , :acosh , :atanh , :log , :log2 , :log10 ,
77 :lgamma , :log1p )
88 @eval begin
9- ($ f)(x:: Float64 ) = ccall (($ (string (f)),libm), Float64, (Float64,), x)
10- ($ f)(x:: Float32 ) = ccall (($ (string (f," f" )),libm), Float32, (Float32,), x)
9+ Base . @assume_effects :total ($ f)(x:: Float64 ) = ccall (($ (string (f)),libm), Float64, (Float64,), x)
10+ Base . @assume_effects :total ($ f)(x:: Float32 ) = ccall (($ (string (f," f" )),libm), Float32, (Float32,), x)
1111 ($ f)(x:: Real ) = ($ f)(float (x))
1212 if $ f != = :lgamma
1313 ($ f)(x) = (Base.$ f)(x)
2525
2626# Would be more efficient to remove the domain check in Base.sqrt(),
2727# but this doesn't seem easy to do.
28+ Base. @assume_effects :nothrow sqrt (x:: T ) where {T<: Union{Float16, Float32, Float64} } = x < 0.0 ? T (NaN ) : Base. sqrt (x)
2829sqrt (x:: T ) where {T<: AbstractFloat } = x < 0.0 ? T (NaN ) : Base. sqrt (x)
2930sqrt (x:: Real ) = sqrt (float (x))
3031
3132# Don't override built-in ^ operator
32- pow (x:: Float64 , y:: Float64 ) = ccall ((:pow ,libm), Float64, (Float64,Float64), x, y)
33- pow (x:: Float32 , y:: Float32 ) = ccall ((:powf ,libm), Float32, (Float32,Float32), x, y)
33+ Base . @assume_effects :total pow (x:: Float64 , y:: Float64 ) = ccall ((:pow ,libm), Float64, (Float64,Float64), x, y)
34+ Base . @assume_effects :total pow (x:: Float32 , y:: Float32 ) = ccall ((:powf ,libm), Float32, (Float32,Float32), x, y)
3435# We `promote` first before converting to floating pointing numbers to ensure that
3536# e.g. `pow(::Float32, ::Int)` ends up calling `pow(::Float32, ::Float32)`
3637pow (x:: Real , y:: Real ) = pow (promote (x, y)... )
0 commit comments