Skip to content

add const keyword to broadcasted AndAnd #43483

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

Merged
merged 3 commits into from
Dec 20, 2021

Conversation

Pramodh-G
Copy link
Contributor

Fixes #43470 .

@oscardssmith oscardssmith added merge me PR is reviewed. Merge when all tests are passing bugfix This change fixes an existing bug labels Dec 19, 2021
@aviatesk aviatesk removed the merge me PR is reviewed. Merge when all tests are passing label Dec 19, 2021
@aviatesk
Copy link
Member

Please add a test that demonstrates the inferrability improved by this PR.

@Pramodh-G
Copy link
Contributor Author

After:

julia> x = randn(2)
2-element Vector{Float64}:
 -1.2451537541682325
 -1.2242484085305838

julia> y = randn(2)
2-element Vector{Float64}:
 0.1509648501453017
 1.758750943063555

julia> function dotandand(x,y) 
           (x .> 0.0) .&& (y .> 0.0)
       end
dotandand (generic function with 1 method)

julia> @code_warntype dotandand(x, y)
MethodInstance for dotandand(::Vector{Float64}, ::Vector{Float64})
  from dotandand(x, y) in Main at REPL[3]:1
Arguments
  #self#::Core.Const(dotandand)
  x::Vector{Float64}
  y::Vector{Float64}
Body::BitVector
1%1 = Base.broadcasted(Main.:>, x, 0.0)::Core.PartialStruct(Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(>), Tuple{Vector{Float64}, Float64}}, Any[Core.Const(>), Core.PartialStruct(Tuple{Vector{Float64}, Float64}, Any[Vector{Float64}, Core.Const(0.0)]), Core.Const(nothing)])
│   %2 = Base.broadcasted(Main.:>, y, 0.0)::Core.PartialStruct(Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(>), Tuple{Vector{Float64}, Float64}}, Any[Core.Const(>), Core.PartialStruct(Tuple{Vector{Float64}, Float64}, Any[Vector{Float64}, Core.Const(0.0)]), Core.Const(nothing)])
│   %3 = Base.broadcasted(Base.andand, %1, %2)::Core.PartialStruct(Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Base.Broadcast.var"#3#4"{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(>), Tuple{Vector{Float64}, Float64}}}, Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(>), Tuple{Vector{Float64}, Float64}}, Vector{Float64}, Float64}}, Any[Core.PartialStruct(Base.Broadcast.var"#3#4"{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(>), Tuple{Vector{Float64}, Float64}}}, Any[Core.PartialStruct(Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(>), Tuple{Vector{Float64}, Float64}}, Any[Core.Const(>), Core.PartialStruct(Tuple{Vector{Float64}, Float64}, Any[Vector{Float64}, Core.Const(0.0)]), Core.Const(nothing)])]), Core.PartialStruct(Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(>), Tuple{Vector{Float64}, Float64}}, Vector{Float64}, Float64}, Any[Core.PartialStruct(Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(>), Tuple{Vector{Float64}, Float64}}, Any[Core.Const(>), Core.PartialStruct(Tuple{Vector{Float64}, Float64}, Any[Vector{Float64}, Core.Const(0.0)]), Core.Const(nothing)]), Vector{Float64}, Core.Const(0.0)]), Core.Const(nothing)])
│   %4 = Base.materialize(%3)::BitVector
└──      return %4

@aviatesk aviatesk merged commit 4409c82 into JuliaLang:master Dec 20, 2021
@KristofferC KristofferC mentioned this pull request Jan 5, 2022
23 tasks
KristofferC pushed a commit that referenced this pull request Jan 10, 2022
Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
(cherry picked from commit 4409c82)
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.&& not type stable in Julia 1.7
4 participants