-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NewOptimizer] Better handling in the presence of select value
The benchmarks contain code like this: ``` x::Union{Nothing, Int} result += ifelse(x === nothing, 0, x) ``` which, perhaps somewhat ironically is quite a bit harder on the new optimizer than an equivalent code sequence using ternary operators. The reason for this is that ifelse gets inferred as `Union{Int, Nothing}`, creating a phi node of that type, which then causes a union split + that the optimizer can't really get rid of easily. What this commit does is add some local improvements to help with the situation. First, it adds some minimal back inference during inlining. As a result, when inlining decides to unionsplit `ifelse(x === nothing, 0, x::Union{Nothing, Int})`, it looks back at the definition of `x === nothing`, realizes it's constrained by the union split and inserts the appropriate boolean constant. Next, a new `type_tightening_pass` goes back and annotates more precise types for the inlinined `select_value` and phi nodes. This is sufficient to get the above code to behave reasonably and should hopefully fix the performance regression on the various union sum benchmarks seen in #26795.
- Loading branch information
Showing
5 changed files
with
184 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters