-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
SROA: generalize unswitchtupleunion optimization
#50502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. |
59aad42 to
d7bf34a
Compare
|
@nanosoldier |
|
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. |
This commit improves SROA pass by extending the `unswitchtupleunion`
optimization to handle the general parametric types, e.g.:
```julia
julia> struct A{T}
x::T
end;
julia> function foo(a1, a2, c)
t = c ? A(a1) : A(a2)
return getfield(t, :x)
end;
julia> only(Base.code_ircode(foo, (Int,Float64,Bool); optimize_until="SROA"))
```
> Before
```
2 1 ─ goto #3 if not _4 │
2 ─ %2 = %new(A{Int64}, _2)::A{Int64} │╻ A
└── goto #4 │
3 ─ %4 = %new(A{Float64}, _3)::A{Float64} │╻ A
4 ┄ %5 = φ (#2 => %2, #3 => %4)::Union{A{Float64}, A{Int64}} │
3 │ %6 = Main.getfield(%5, :x)::Union{Float64, Int64} │
└── return %6 │
=> Union{Float64, Int64}
```
> After
```
julia> only(Base.code_ircode(foo, (Int,Float64,Bool); optimize_until="SROA"))
2 1 ─ goto #3 if not _4 │
2 ─ nothing::A{Int64} │╻ A
└── goto #4 │
3 ─ nothing::A{Float64} │╻ A
4 ┄ %8 = φ (#2 => _2, #3 => _3)::Union{Float64, Int64} │
│ nothing::Union{A{Float64}, A{Int64}}
3 │ %6 = %8::Union{Float64, Int64} │
└── return %6 │
=> Union{Float64, Int64}
```
d7bf34a to
ab1a6d6
Compare
|
@nanosoldier |
|
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. |
Keno
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, why not
|
EDIT: this PR actually fixes them. |
|
(it hasnt been reverted) |
@maleadt At which package does the regression happen? |
|
See the latest daily, https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_date/2023-07/11/report.html, most of the crashes point to this PR. For example, StaticArrayInterface, VectorizationBase, StrideArraysCore, ImageMorphology, ... |
|
Thanks! |
|
Ah, OK. I saw |
This commit improves SROA pass by extending the
unswitchtupleunionoptimization to handle the general parametric types, e.g.:@nanosoldier
runbenchmarks("inference", vs=":master")