You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct Wrapper{T} <:DenseVector{T}
data::Vector{T}end
Base.length(w::Wrapper) =length(w.data)
Base.size(w::Wrapper) =size(w.data)
Base.unsafe_convert(::Type{Ptr{T}}, w::Wrapper{T}) where {T} = Base.unsafe_convert(Ptr{T}, w.data)
@inlinefunction Base.getindex(w::Wrapper, i::Integer)
@boundscheck (0< i ≤length(w)) ||throw(BoundsError(w, i))
GC.@preserve w begin
v =unsafe_load(pointer(w), i)
end
v
end@inlinefunction Base.setindex!(pw::Wrapper{T}, v, i::Integer) where {T}
@boundscheck (0< i ≤length(w)) ||throw(BoundsError(w, i))
GC.@preserve w beginunsafe_store!(pointer(w), v, i)
end
v
endfunctionmysum(x)
s =zero(eltype(x))
@inbounds@simdfor i ineachindex(x)
s += x[i]
end
s
end
By setting JULIA_LLVM_ARGS to --pass-remarks-analysis=loop-vectorize --pass-remarks-missed=loop-vectorize --pass-remarks=loop-vectorize, I get:
remark: simdloop.jl:75:0: loop not vectorized: instruction cannot be vectorized
remark: simdloop.jl:75:0: loop not vectorized
By setting
JULIA_LLVM_ARGS
to--pass-remarks-analysis=loop-vectorize --pass-remarks-missed=loop-vectorize --pass-remarks=loop-vectorize
, I get:Removing the
GC.@preserve
yields:I believe the
GC.@preserve
is necessary, so it'd be nice if it didn't carry a potential performance penalty.The text was updated successfully, but these errors were encountered: