Skip to content

Commit

Permalink
use firstindex in CartesianIndices's simd_index
Browse files Browse the repository at this point in the history
`first(Base.axes1())` works well, but `length(::StepRange)` won't be omitted by LLVM if `step` is unknown at compile time.
  • Loading branch information
N5N3 committed Dec 23, 2021
1 parent f9d771e commit 86d4375
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,8 @@ module IteratorsMD
simd_inner_length(iter::CartesianIndices, I::CartesianIndex) = Base.length(iter.indices[1])

simd_index(iter::CartesianIndices{0}, ::CartesianIndex, I1::Int) = first(iter)
@propagate_inbounds function simd_index(iter::CartesianIndices, Ilast::CartesianIndex, I1::Int)
CartesianIndex(getindex(iter.indices[1], I1+first(Base.axes1(iter.indices[1]))), Ilast.I...)
end
@propagate_inbounds simd_index(iter::CartesianIndices, Ilast::CartesianIndex, I1::Int) =
CartesianIndex(iter.indices[1][I1+firstindex(iter.indices[1])], Ilast)

# Split out the first N elements of a tuple
@inline function split(t, V::Val)
Expand Down

0 comments on commit 86d4375

Please sign in to comment.