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

improve inference of CPU_THREADS in Sys.__init__ #54384

Merged
merged 1 commit into from
May 7, 2024
Merged

Conversation

topolarity
Copy link
Member

Without this change, the compiler fails to notice that env_threads isa Int in the fall-through case, leading to a union-split with a branch that is in fact unreachable:

43 ┄ %109 = φ (#41 => %105, #42 => %108)::Union{Nothing, Int64}
│    %110 = (%109 isa Int64)::Bool
└───        goto #45 if not %110
...
45 ─ %126 = π (%109, Nothing)
│           Base.convert(Int64, %126)::Union{}
└───        unreachable

After this change, the union-split is eliminated.

Without this change, the compiler fails to notice that
`env_threads isa Int` in the fall-through case, leading to a union-split
with a branch that is in fact unreachable:

```
43 ┄ %109 = φ (#41 => %105, #42 => %108)::Union{Nothing, Int64}
│    %110 = (%109 isa Int64)::Bool
└───        goto #45 if not %110
...
45 ─ %126 = π (%109, Nothing)
│           Base.convert(Int64, %126)::Union{}
└───        unreachable
```

Co-authored-by: Jeff Bezanson <[email protected]>
@topolarity topolarity changed the title improve inference of CPU_THREADS in Sys.__init__ improve inference of CPU_THREADS in Sys.__init__ May 6, 2024
@aviatesk
Copy link
Member

aviatesk commented May 7, 2024

Just for record: the root inference issue here is #43130.

@aviatesk aviatesk merged commit 99bda02 into master May 7, 2024
8 checks passed
@aviatesk aviatesk deleted the ct/sys-init-union branch May 7, 2024 04:31
lazarusA pushed a commit to lazarusA/julia that referenced this pull request Jul 12, 2024
Without this change, the compiler fails to notice that `env_threads isa
Int` in the fall-through case, leading to a union-split with a branch
that is in fact unreachable:

```
43 ┄ %109 = φ (JuliaLang#41 => %105, JuliaLang#42 => %108)::Union{Nothing, Int64}
│    %110 = (%109 isa Int64)::Bool
└───        goto JuliaLang#45 if not %110
...
45 ─ %126 = π (%109, Nothing)
│           Base.convert(Int64, %126)::Union{}
└───        unreachable
```

After this change, the union-split is eliminated.

Co-authored-by: Jeff Bezanson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants