-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
better effects for iterate
for Memory
and Array
#58755
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
better effects for iterate
for Memory
and Array
#58755
Conversation
19ac0f2
to
7989b96
Compare
This comment was marked as outdated.
This comment was marked as outdated.
NB: I didn't check yet, but if PR #58754 gets merged, it might be possible to just delete the EDIT: just checked, it's true, after #58754 the # no bounds checking, as expected
code_llvm(iterate, Tuple{Vector{Float32}, Int})
code_llvm(iterate, Tuple{Memory{Float32}, Int})
@eval Base function _iterate_array(A::Union{Memory, Array}, i::Int)
@inline
(i - 1)%UInt < length(A)%UInt ? (A[i], i + 1) : nothing
end
@eval Base iterate(A::Memory, i=1) = (@inline; _iterate_array(A, i))
@eval Base iterate(A::Array, i=1) = (@inline; _iterate_array(A, i))
# still no bounds checking!
code_llvm(iterate, Tuple{Vector{Float32}, Int})
code_llvm(iterate, Tuple{Memory{Float32}, Int}) |
7989b96
to
a8c8cae
Compare
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.
f5b3026
to
0e38f1b
Compare
iterate(A::Memory, i=1) = (@inline; (i - 1)%UInt < length(A)%UInt ? (@inbounds A[i], i + 1) : nothing) | ||
function _iterate_array(A::Union{Memory, Array}, i::Int) | ||
@inline | ||
(i - 1)%UInt < length(A)%UInt ? (A[i], i + 1) : nothing |
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.
Could (should?) this also become _checkbounds_array(Bool, A, i)
?
After PR #58754 the bounds checking is eliminated by LLVM even without
@inbounds
, so delete@inbounds
to allow thenoub
effect to be inferred.Also deduplicate and test for good effect inference.