-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
help bounds checking to be eliminated for getindex(::Memory, ::Int)
#58754
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
help bounds checking to be eliminated for getindex(::Memory, ::Int)
#58754
Conversation
Reproducer: function g(a::AbstractArray{Float32}, i::Int)
@inline let
if checkbounds(Bool, a, i)
a[i]
else
Float32(0)
end
end
end
code_llvm(g, Tuple{Memory{Float32}, Int}; debuginfo=:none) # there should be no more bounds checking after this PR |
d55a60e
to
c334dec
Compare
Second try for PR JuliaLang#58741. This moves the `getindex(::Memory, ::Int)` bounds check to Julia, which is how it's already done for `getindex(::Array, ::Int)`, so I guess it's correct. Also deduplicate the bounds checking code while at it.
c334dec
to
9dd4bda
Compare
@nanosoldier |
At a quick glance, this seems to help quite a bit for JuliaArrays/FixedSizeArrays.jl#142, but not fully close the gap. |
#58768 should also hopefully help with this (once the codegen gets updated to work with this) |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. |
benchmarks look totally meaningless (we seem to be missing any Memory benchmarks). That said, lgtm. |
I tried to reproduce one regression and one perf improvement locally, both turned out to be noise. |
Merge? I'd like to rebase #58755 on top of this. |
After PR JuliaLang#58754 the bounds checking is eliminated by LLVM even without asserting `inbounds`, so delete `inbounds` to allow the `noub` effect to be inferred. Also deduplicate and test for good effect inference.
After PR JuliaLang#58754 the bounds checking is eliminated by LLVM even without asserting `inbounds`, so delete `inbounds` to allow the `noub` effect to be inferred. Also deduplicate and test for good effect inference.
Second try for PR #58741.
This moves the
getindex(::Memory, ::Int)
bounds check to Julia, which is how it's already done forgetindex(::Array, ::Int)
, so I guess it's correct.Also deduplicate the bounds checking code while at it.