Skip to content

Commit 528d4ed

Browse files
gbaraldiKristofferC
authored andcommitted
Make reinterpret specialize fully. (#50670)
Fixes #50612 The issue here was the reinterpret change made a bunch of operations like `Core.bitcast(UInt64,24)` not fold, even though they are fully known at compile time. That made `UInt32(Char)` not inline which then caused the regression. (cherry picked from commit dc06468)
1 parent 291dc6b commit 528d4ed

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

base/essentials.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ julia> reinterpret(Tuple{UInt16, UInt8}, (0x01, 0x0203))
571571
otherwise be prevented by the type's constructors and methods. Unexpected behavior
572572
may result without additional validation.
573573
"""
574-
function reinterpret(Out::Type, x::In) where {In}
575-
if isprimitivetype(Out) && isprimitivetype(In)
574+
function reinterpret(::Type{Out}, x) where {Out}
575+
if isprimitivetype(Out) && isprimitivetype(typeof(x))
576576
return bitcast(Out, x)
577577
end
578578
# only available when Base is fully loaded.

test/compiler/inline.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,3 +2061,7 @@ let src = code_typed1((Union{DataType,UnionAll},); interp=NoCompileSigInvokes())
20612061
(x.args[1]::MethodInstance).specTypes == Tuple{typeof(no_compile_sig_invokes),UnionAll}
20622062
end == 1
20632063
end
2064+
2065+
# https://github.com/JuliaLang/julia/issues/50612
2066+
f50612(x) = UInt32(x)
2067+
@test all(!isinvoke(:UInt32),get_code(f50612,Tuple{Char}))

0 commit comments

Comments
 (0)