Skip to content
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

optimizer: enhance SROA, enable PhiNode load forwarding with uninitialized fields #43208

Merged
merged 1 commit into from
Nov 29, 2021

Conversation

aviatesk
Copy link
Member

This commit addresses this TODO comment.
Now SROA can eliminate this sort of allocation:

let src = code_typed((Bool,)) do cond
        r = Ref{Any}()
        if cond
            r[] = 42
        else
            r[] = 32
        end
        return r[]
    end |> only |> first
    @test !any(isnew, src.code)
end

@aviatesk aviatesk added the compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) label Nov 24, 2021
@aviatesk
Copy link
Member Author

@nanosoldier runbenchmarks("broadcast" || "sparse" || "array" || "union", vs=":master")

@aviatesk aviatesk changed the title optimizer: enhance SROA, enable PhiNodefy load forwarding with uninitialized fields optimizer: enhance SROA, enable PhiNode load forwarding with uninitialized fields Nov 24, 2021
@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@vtjnash vtjnash requested a review from ianatol November 24, 2021 18:41
@aviatesk aviatesk force-pushed the avi/sroa branch 2 times, most recently from 21fbd77 to 926ac20 Compare November 25, 2021 06:19
@aviatesk aviatesk changed the base branch from master to avi/ssair November 25, 2021 11:00
Base automatically changed from avi/ssair to master November 25, 2021 13:09
…itialized allocations

This commit addresses this [TODO comment](https://github.com/JuliaLang/julia/blob/3a5146f6b94e32bef5a812619068f82218b5482c/base/compiler/ssair/passes.jl#L831-L832).
Now SROA can eliminate this sort of allocation:
```julia
let src = code_typed((Bool,)) do cond
        r = Ref{Any}()
        if cond
            r[] = 42
        else
            r[] = 32
        end
        return r[]
    end |> only |> first
    @test !any(isnew, src.code)
end
```
@aviatesk aviatesk merged commit c624d4f into master Nov 29, 2021
@aviatesk aviatesk deleted the avi/sroa branch November 29, 2021 02:18
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
…aLang#43208)

This commit addresses this [TODO comment](https://github.com/JuliaLang/julia/blob/3a5146f6b94e32bef5a812619068f82218b5482c/base/compiler/ssair/passes.jl#L831-L832),
and allows SROA pass to form `PhiNode`s for uninitialized fields when we
can prove there are safe `setfield!` calls in all dominated control flows.
Now SROA can eliminate this sort of allocation:
```julia
let src = code_typed((Bool,)) do cond
        r = Ref{Any}()
        if cond
            r[] = 42
        else
            r[] = 32
        end
        return r[]
    end |> only |> first
    @test !any(isnew, src.code)
end
```
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
…aLang#43208)

This commit addresses this [TODO comment](https://github.com/JuliaLang/julia/blob/3a5146f6b94e32bef5a812619068f82218b5482c/base/compiler/ssair/passes.jl#L831-L832),
and allows SROA pass to form `PhiNode`s for uninitialized fields when we
can prove there are safe `setfield!` calls in all dominated control flows.
Now SROA can eliminate this sort of allocation:
```julia
let src = code_typed((Bool,)) do cond
        r = Ref{Any}()
        if cond
            r[] = 42
        else
            r[] = 32
        end
        return r[]
    end |> only |> first
    @test !any(isnew, src.code)
end
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants