Skip to content

Inference regression on 1.7-RC2 and master (relative to 1.6.3) #42839

@Sacha0

Description

@Sacha0

@NHDaly (🙏) and I reduced the following out of a regression on Julia 1.7-RC2. Happily, on Julia 1.6.3:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.3 (2021-09-23)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |

julia> begin
           cat_storage_type(::Type{T}) where T = T
           cat_storage_type(::Type{T}) where {T<:Tuple} = Tuple{_cat_storage_type_tuple(T)...}

           _cat_storage_type_tuple(::Type{Tuple{}}) = ()
           function _cat_storage_type_tuple(::Type{T}) where {T<:Tuple}
               return (
                   cat_storage_type(fieldtype(T, 1)),
                   _cat_storage_type_tuple(Base.tuple_type_tail(T))...,
               )
           end
       end
_cat_storage_type_tuple (generic function with 2 methods)

julia> @code_warntype cat_storage_type(Tuple{NTuple{3, UInt8}})
Variables
  #self#::Core.Const(cat_storage_type)
  #unused#::Core.Const(Tuple{Tuple{UInt8, UInt8, UInt8}})

Body::Type{Tuple{Tuple{UInt8, UInt8, UInt8}}}
1 ─ %1 = Core.tuple(Main.Tuple)::Core.Const((Tuple,))
│   %2 = Main._cat_storage_type_tuple($(Expr(:static_parameter, 1)))::Core.Const((Tuple{UInt8, UInt8, UInt8},))
│   %3 = Core._apply_iterate(Base.iterate, Core.apply_type, %1, %2)::Core.Const(Tuple{Tuple{UInt8, UInt8, UInt8}})
└──      return %3

While on 1.7-RC2:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.0-rc2 (2021-10-20)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |

julia> begin
           cat_storage_type(::Type{T}) where T = T
           cat_storage_type(::Type{T}) where {T<:Tuple} = Tuple{_cat_storage_type_tuple(T)...}

           _cat_storage_type_tuple(::Type{Tuple{}}) = ()
           function _cat_storage_type_tuple(::Type{T}) where {T<:Tuple}
               return (
                   cat_storage_type(fieldtype(T, 1)),
                   _cat_storage_type_tuple(Base.tuple_type_tail(T))...,
               )
           end
       end
_cat_storage_type_tuple (generic function with 2 methods)

julia> @code_warntype cat_storage_type(Tuple{NTuple{3, UInt8}})
MethodInstance for cat_storage_type(::Type{Tuple{Tuple{UInt8, UInt8, UInt8}}})
  from cat_storage_type(::Type{T}) where T<:Tuple in Main at REPL[1]:3
Static Parameters
  T = Tuple{Tuple{UInt8, UInt8, UInt8}}
Arguments
  #self#::Core.Const(cat_storage_type)
  _::Core.Const(Tuple{Tuple{UInt8, UInt8, UInt8}})
Body::Type{<:Tuple}
1 ─ %1 = Core.tuple(Main.Tuple)::Core.Const((Tuple,))
│   %2 = Main._cat_storage_type_tuple($(Expr(:static_parameter, 1)))::Tuple{Type}
│   %3 = Core._apply_iterate(Base.iterate, Core.apply_type, %1, %2)::Type{<:Tuple}
└──      return %3

And on several day old master:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.0-DEV.702 (2021-10-10)
 _/ |\__'_|_|_|\__'_|  |  master/82257229c9 (fork: 1 commits, 18 days)
|__/                   |

julia> begin
           cat_storage_type(::Type{T}) where T = T
           cat_storage_type(::Type{T}) where {T<:Tuple} = Tuple{_cat_storage_type_tuple(T)...}

           _cat_storage_type_tuple(::Type{Tuple{}}) = ()
           function _cat_storage_type_tuple(::Type{T}) where {T<:Tuple}
               return (
                   cat_storage_type(fieldtype(T, 1)),
                   _cat_storage_type_tuple(Base.tuple_type_tail(T))...,
               )
           end
       end
_cat_storage_type_tuple (generic function with 2 methods)

julia> @code_warntype cat_storage_type(Tuple{NTuple{3, UInt8}})
MethodInstance for cat_storage_type(::Type{Tuple{Tuple{UInt8, UInt8, UInt8}}})
  from cat_storage_type(::Type{T}) where T<:Tuple in Main at REPL[1]:3
Static Parameters
  T = Tuple{Tuple{UInt8, UInt8, UInt8}}
Arguments
  #self#::Core.Const(cat_storage_type)
  _::Core.Const(Tuple{Tuple{UInt8, UInt8, UInt8}})
Body::Type{<:Tuple}
1 ─ %1 = Core.tuple(Main.Tuple)::Core.Const((Tuple,))
│   %2 = Main._cat_storage_type_tuple($(Expr(:static_parameter, 1)))::Tuple{Type}
│   %3 = Core._apply_iterate(Base.iterate, Core.apply_type, %1, %2)::Type{<:Tuple}
└──      return %3

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:inferenceType inferenceregressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions