Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ end

# Restrict inlining to hardware-supported arithmetic types, which
# are fast enough to benefit from inlining.
const HWReal = Union{Int8,Int16,Int32,Int64,UInt8,UInt16,UInt32,UInt64,Float32,Float64}
const HWReal = Union{Int8,Int16,Int32,Int64,UInt8,UInt16,UInt32,UInt64,Float16,Float32,Float64}
const HWNumber = Union{HWReal, Complex{<:HWReal}, Rational{<:HWReal}}

# Inline x^2 and x^3 for Val
Expand Down
17 changes: 17 additions & 0 deletions test/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,20 @@ end
@test Base.infer_effects(gcdx, (Int,Int)) |> Core.Compiler.is_foldable
@test Base.infer_effects(invmod, (Int,Int)) |> Core.Compiler.is_foldable
@test Base.infer_effects(binomial, (Int,Int)) |> Core.Compiler.is_foldable

@testset "literal power" begin
@testset for T in Base.uniontypes(Base.HWReal)
ns = (T(0), T(1), T(5))
if T <: AbstractFloat
ns = (ns..., T(3.14), T(-2.71))
end
for n in ns
@test n ^ 0 === T(1)
@test n ^ 1 === n
@test n ^ 2 === n * n
@test n ^ 3 === n * n * n
@test n ^ -1 ≈ inv(n)
@test n ^ -2 ≈ inv(n) * inv(n)
end
end
end