-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Type-stable codegen for specialized in(v, ::Tuple)
#54026
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,9 +328,21 @@ end | |
@test lt5(4) && !lt5(5) | ||
end | ||
|
||
@testset "in tuples" begin | ||
@test ∈(5, (1,5,10,11)) | ||
@test ∉(0, (1,5,10,11)) | ||
@test ∈(5, (1,"hi","hey",5.0)) | ||
@test ∉(0, (1,"hi","hey",5.0)) | ||
@test ∈(5, (5,)) | ||
@test ∉(0, (5,)) | ||
@test ∉(5, ()) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can tell, there weren't any tests for |
||
|
||
@testset "ni" begin | ||
@test ∋([1,5,10,11], 5) | ||
@test !∋([1,10,11], 5) | ||
@test ∋((1,5,10,11), 5) | ||
@test ∌((1,10,11), 5) | ||
@test ∋(5)([5,1]) | ||
@test !∋(42)([0,1,100]) | ||
@test ∌(0)(1:10) | ||
|
@@ -367,7 +379,8 @@ end | |
@test B46327() <= B46327() | ||
end | ||
|
||
@testset "concrete eval `x in itr::Tuple`" begin | ||
@testset "inference for `x in itr::Tuple`" begin | ||
# concrete evaluation | ||
@test Core.Compiler.is_foldable(Base.infer_effects(in, (Int,Tuple{Int,Int,Int}))) | ||
@test Core.Compiler.is_foldable(Base.infer_effects(in, (Char,Tuple{Char,Char,Char}))) | ||
for i = (1,2,3) | ||
|
@@ -377,10 +390,23 @@ end | |
end |> only == Val{true} | ||
end | ||
end | ||
@test Base.return_types() do | ||
@test Base.infer_return_type() do | ||
Val(4 in (1,2,3)) | ||
end |> only == Val{false} | ||
@test Base.return_types() do | ||
end == Val{false} | ||
@test Base.infer_return_type() do | ||
Val('1' in ('1','2','3')) | ||
end |> only == Val{true} | ||
end == Val{true} | ||
|
||
# constant propagation | ||
@test Base.infer_return_type((Int,Int)) do x, y | ||
Val(1 in (x,2,y)) | ||
end >: Val{true} | ||
@test Base.infer_return_type((Int,Int)) do x, y | ||
Val(2 in (x,2,y)) | ||
end == Val{true} | ||
|
||
# should use the loop implementation given large tuples to avoid inference blowup | ||
let t = ntuple(x->'A', 10000); | ||
@test Base.infer_return_type(in, (Char,typeof(t))) == Bool | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you help me understand why you moved the inline annotation? Does it have any difference, or you just prefer this stylistically? Thanks!
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.
An
@inline
applied to a method carries less weight than an@inline
applied to code block within the method body.The semantics are different, when used within the method body it suggests to inline callees.
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.
BTW can you help review my linked PR, given that you're freshly acquainted with the code?
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.
They have the same effect, but
@inline method def
is defined in base/expr.jl and is not available at this point of loading base/operators.jl when building system image. the version which is used without any arguments on the other hand is defined at the very early stage of sysimg build, so we can use it even before loading base/expr.jl.