Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/compiler/interpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,26 @@ end
@inline function override_bc_mapreduce(f, op, ::Base.IndexLinear, A::Base.AbstractArrayOrBroadcasted)
inds = Base.LinearIndices(A)
n = length(inds)

HET = Base.IteratorEltype(A)
if HET isa Base.HasEltype
ET = eltype(A)
if (op === Base.:+ || op === Base.add_sum) && Base.isconcretetype(ET) && (ET <: Base.IEEEFloat || ET <: Complex{<:Base.IEEEFloat})
@inbounds i = first(inds)
@inbounds l = last(inds)
s = zero(ET)
while i <= l
@inbounds Ai = A[i]
i+=1
s = op(s, f(Ai))
@simdloop
end
return s
end
end

if n == 0
return Base.mapreduce_empty_iter(f, op, A, Base.IteratorEltype(A))
return Base.mapreduce_empty_iter(f, op, A, HET)
elseif n == 1
@inbounds a1 = A[first(inds)]
return Base.mapreduce_first(f, op, a1)
Expand Down
Loading