Skip to content

Incorrect optimization on typejoin in 1.11+ #53590

@KristofferC

Description

@KristofferC

The following PkgEval log https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/0520b80_vs_997b49f/DataStructures.primary.log shows a regression in typejoin where the result inside the function is different from outside. The code below reproduces that (with a debug statement to see what is being executed inside there and with an interpreted result which agrees with the manually evaluated typejoin call):

julia> using DataStructures, JuliaInterpreter

julia> f(x) = x % 2 == 0 ? convert(Int8, x) : convert(Float16, x)
f (generic function with 1 method)

julia> n = 5
5

julia> l = MutableLinkedList{Int}(1:n...)
MutableLinkedList{Int64}(1, 2, 3, 4, 5)

julia> map(f, l)
# (typejoin(S, typeof(el)), S, typeof(el)) = (Float16, Float16, Int8)
MutableLinkedList{Float16}(1.0, 2.0, 3.0, 4.0, 5.0)

julia> typejoin(Float16, Int8)
Real

julia> @interpret map(f, l)
# (typejoin(S, typeof(el)), S, typeof(el)) = (Real, Float16, Int8)
MutableLinkedList{Real}(1.0, 2, 3.0, 4, 5.0)

The relevant code in DataStructures.jl is https://github.com/JuliaCollections/DataStructures.jl/blob/5451407b8c7e66a2e572d2f50c0f75e675016d35/src/mutable_list.jl#L75-L89

Bisected to 8307dbf (cc @vtjnash)

Metadata

Metadata

Assignees

Labels

compiler:optimizerOptimization passes (mostly in base/compiler/ssair/)regressionRegression in behavior compared to a previous version

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions