Skip to content

Commit

Permalink
Changed check_top_bit InexactError (#33202)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobnissen authored and JeffBezanson committed Sep 11, 2019
1 parent 24ddae9 commit c48126f
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,9 @@ function is_top_bit_set(x::Union{Int8,UInt8})
eq_int(lshr_int(x, 7), trunc_int(typeof(x), 1))
end

function check_top_bit(x)
function check_top_bit(::Type{To}, x) where {To}
@_inline_meta
is_top_bit_set(x) && throw_inexacterror(:check_top_bit, typeof(x), x)
is_top_bit_set(x) && throw_inexacterror(:check_top_bit, To, x)
x
end

Expand All @@ -596,22 +596,22 @@ toInt8(x::Int16) = checked_trunc_sint(Int8, x)
toInt8(x::Int32) = checked_trunc_sint(Int8, x)
toInt8(x::Int64) = checked_trunc_sint(Int8, x)
toInt8(x::Int128) = checked_trunc_sint(Int8, x)
toInt8(x::UInt8) = bitcast(Int8, check_top_bit(x))
toInt8(x::UInt16) = checked_trunc_sint(Int8, check_top_bit(x))
toInt8(x::UInt32) = checked_trunc_sint(Int8, check_top_bit(x))
toInt8(x::UInt64) = checked_trunc_sint(Int8, check_top_bit(x))
toInt8(x::UInt128) = checked_trunc_sint(Int8, check_top_bit(x))
toInt8(x::UInt8) = bitcast(Int8, check_top_bit(Int8, x))
toInt8(x::UInt16) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
toInt8(x::UInt32) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
toInt8(x::UInt64) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
toInt8(x::UInt128) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
toInt8(x::Bool) = and_int(bitcast(Int8, x), Int8(1))
toInt16(x::Int8) = sext_int(Int16, x)
toInt16(x::Int16) = x
toInt16(x::Int32) = checked_trunc_sint(Int16, x)
toInt16(x::Int64) = checked_trunc_sint(Int16, x)
toInt16(x::Int128) = checked_trunc_sint(Int16, x)
toInt16(x::UInt8) = zext_int(Int16, x)
toInt16(x::UInt16) = bitcast(Int16, check_top_bit(x))
toInt16(x::UInt32) = checked_trunc_sint(Int16, check_top_bit(x))
toInt16(x::UInt64) = checked_trunc_sint(Int16, check_top_bit(x))
toInt16(x::UInt128) = checked_trunc_sint(Int16, check_top_bit(x))
toInt16(x::UInt16) = bitcast(Int16, check_top_bit(Int16, x))
toInt16(x::UInt32) = checked_trunc_sint(Int16, check_top_bit(Int16, x))
toInt16(x::UInt64) = checked_trunc_sint(Int16, check_top_bit(Int16, x))
toInt16(x::UInt128) = checked_trunc_sint(Int16, check_top_bit(Int16, x))
toInt16(x::Bool) = and_int(zext_int(Int16, x), Int16(1))
toInt32(x::Int8) = sext_int(Int32, x)
toInt32(x::Int16) = sext_int(Int32, x)
Expand All @@ -620,9 +620,9 @@ toInt32(x::Int64) = checked_trunc_sint(Int32, x)
toInt32(x::Int128) = checked_trunc_sint(Int32, x)
toInt32(x::UInt8) = zext_int(Int32, x)
toInt32(x::UInt16) = zext_int(Int32, x)
toInt32(x::UInt32) = bitcast(Int32, check_top_bit(x))
toInt32(x::UInt64) = checked_trunc_sint(Int32, check_top_bit(x))
toInt32(x::UInt128) = checked_trunc_sint(Int32, check_top_bit(x))
toInt32(x::UInt32) = bitcast(Int32, check_top_bit(Int32, x))
toInt32(x::UInt64) = checked_trunc_sint(Int32, check_top_bit(Int32, x))
toInt32(x::UInt128) = checked_trunc_sint(Int32, check_top_bit(Int32, x))
toInt32(x::Bool) = and_int(zext_int(Int32, x), Int32(1))
toInt64(x::Int8) = sext_int(Int64, x)
toInt64(x::Int16) = sext_int(Int64, x)
Expand All @@ -632,8 +632,8 @@ toInt64(x::Int128) = checked_trunc_sint(Int64, x)
toInt64(x::UInt8) = zext_int(Int64, x)
toInt64(x::UInt16) = zext_int(Int64, x)
toInt64(x::UInt32) = zext_int(Int64, x)
toInt64(x::UInt64) = bitcast(Int64, check_top_bit(x))
toInt64(x::UInt128) = checked_trunc_sint(Int64, check_top_bit(x))
toInt64(x::UInt64) = bitcast(Int64, check_top_bit(Int64, x))
toInt64(x::UInt128) = checked_trunc_sint(Int64, check_top_bit(Int64, x))
toInt64(x::Bool) = and_int(zext_int(Int64, x), Int64(1))
toInt128(x::Int8) = sext_int(Int128, x)
toInt128(x::Int16) = sext_int(Int128, x)
Expand All @@ -644,9 +644,9 @@ toInt128(x::UInt8) = zext_int(Int128, x)
toInt128(x::UInt16) = zext_int(Int128, x)
toInt128(x::UInt32) = zext_int(Int128, x)
toInt128(x::UInt64) = zext_int(Int128, x)
toInt128(x::UInt128) = bitcast(Int128, check_top_bit(x))
toInt128(x::UInt128) = bitcast(Int128, check_top_bit(Int128, x))
toInt128(x::Bool) = and_int(zext_int(Int128, x), Int128(1))
toUInt8(x::Int8) = bitcast(UInt8, check_top_bit(x))
toUInt8(x::Int8) = bitcast(UInt8, check_top_bit(UInt8, x))
toUInt8(x::Int16) = checked_trunc_uint(UInt8, x)
toUInt8(x::Int32) = checked_trunc_uint(UInt8, x)
toUInt8(x::Int64) = checked_trunc_uint(UInt8, x)
Expand All @@ -657,8 +657,8 @@ toUInt8(x::UInt32) = checked_trunc_uint(UInt8, x)
toUInt8(x::UInt64) = checked_trunc_uint(UInt8, x)
toUInt8(x::UInt128) = checked_trunc_uint(UInt8, x)
toUInt8(x::Bool) = and_int(bitcast(UInt8, x), UInt8(1))
toUInt16(x::Int8) = sext_int(UInt16, check_top_bit(x))
toUInt16(x::Int16) = bitcast(UInt16, check_top_bit(x))
toUInt16(x::Int8) = sext_int(UInt16, check_top_bit(UInt16, x))
toUInt16(x::Int16) = bitcast(UInt16, check_top_bit(UInt16, x))
toUInt16(x::Int32) = checked_trunc_uint(UInt16, x)
toUInt16(x::Int64) = checked_trunc_uint(UInt16, x)
toUInt16(x::Int128) = checked_trunc_uint(UInt16, x)
Expand All @@ -668,9 +668,9 @@ toUInt16(x::UInt32) = checked_trunc_uint(UInt16, x)
toUInt16(x::UInt64) = checked_trunc_uint(UInt16, x)
toUInt16(x::UInt128) = checked_trunc_uint(UInt16, x)
toUInt16(x::Bool) = and_int(zext_int(UInt16, x), UInt16(1))
toUInt32(x::Int8) = sext_int(UInt32, check_top_bit(x))
toUInt32(x::Int16) = sext_int(UInt32, check_top_bit(x))
toUInt32(x::Int32) = bitcast(UInt32, check_top_bit(x))
toUInt32(x::Int8) = sext_int(UInt32, check_top_bit(UInt32, x))
toUInt32(x::Int16) = sext_int(UInt32, check_top_bit(UInt32, x))
toUInt32(x::Int32) = bitcast(UInt32, check_top_bit(UInt32, x))
toUInt32(x::Int64) = checked_trunc_uint(UInt32, x)
toUInt32(x::Int128) = checked_trunc_uint(UInt32, x)
toUInt32(x::UInt8) = zext_int(UInt32, x)
Expand All @@ -679,22 +679,22 @@ toUInt32(x::UInt32) = x
toUInt32(x::UInt64) = checked_trunc_uint(UInt32, x)
toUInt32(x::UInt128) = checked_trunc_uint(UInt32, x)
toUInt32(x::Bool) = and_int(zext_int(UInt32, x), UInt32(1))
toUInt64(x::Int8) = sext_int(UInt64, check_top_bit(x))
toUInt64(x::Int16) = sext_int(UInt64, check_top_bit(x))
toUInt64(x::Int32) = sext_int(UInt64, check_top_bit(x))
toUInt64(x::Int64) = bitcast(UInt64, check_top_bit(x))
toUInt64(x::Int8) = sext_int(UInt64, check_top_bit(UInt64, x))
toUInt64(x::Int16) = sext_int(UInt64, check_top_bit(UInt64, x))
toUInt64(x::Int32) = sext_int(UInt64, check_top_bit(UInt64, x))
toUInt64(x::Int64) = bitcast(UInt64, check_top_bit(UInt64, x))
toUInt64(x::Int128) = checked_trunc_uint(UInt64, x)
toUInt64(x::UInt8) = zext_int(UInt64, x)
toUInt64(x::UInt16) = zext_int(UInt64, x)
toUInt64(x::UInt32) = zext_int(UInt64, x)
toUInt64(x::UInt64) = x
toUInt64(x::UInt128) = checked_trunc_uint(UInt64, x)
toUInt64(x::Bool) = and_int(zext_int(UInt64, x), UInt64(1))
toUInt128(x::Int8) = sext_int(UInt128, check_top_bit(x))
toUInt128(x::Int16) = sext_int(UInt128, check_top_bit(x))
toUInt128(x::Int32) = sext_int(UInt128, check_top_bit(x))
toUInt128(x::Int64) = sext_int(UInt128, check_top_bit(x))
toUInt128(x::Int128) = bitcast(UInt128, check_top_bit(x))
toUInt128(x::Int8) = sext_int(UInt128, check_top_bit(UInt128, x))
toUInt128(x::Int16) = sext_int(UInt128, check_top_bit(UInt128, x))
toUInt128(x::Int32) = sext_int(UInt128, check_top_bit(UInt128, x))
toUInt128(x::Int64) = sext_int(UInt128, check_top_bit(UInt128, x))
toUInt128(x::Int128) = bitcast(UInt128, check_top_bit(UInt128, x))
toUInt128(x::UInt8) = zext_int(UInt128, x)
toUInt128(x::UInt16) = zext_int(UInt128, x)
toUInt128(x::UInt32) = zext_int(UInt128, x)
Expand Down

0 comments on commit c48126f

Please sign in to comment.