Skip to content

Dotted comparison chains don't fuse with surrounding dotted calls #39600

@mbauman

Description

@mbauman

I'd expect the following to create just one fused loop, but it creates two (two materializes):

julia> Meta.@lower (!).(1 .< A .< 2)
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─ %1 = Base.broadcasted(<, 1, A)
│   %2 = Base.broadcasted(<, A, 2)
│   %3 = Base.broadcasted(&, %1, %2)
│   %4 = Base.materialize(%3)
│   %5 = Base.broadcasted(!, %4)
│   %6 = Base.materialize(%5)
└──      return %6
))))

It should look like:

julia> Meta.@lower  (!).((1 .< A) .& (A .< 2))
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─ %1 = Base.broadcasted(<, 1, A)
│   %2 = Base.broadcasted(<, A, 2)
│   %3 = Base.broadcasted(&, %1, %2)
│   %4 = Base.broadcasted(!, %3)
│   %5 = Base.materialize(%4)
└──      return %5
))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collectioncompiler:loweringSyntax lowering (compiler front end, 2nd stage)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions