Skip to content

Commit b13e9ee

Browse files
committed
fix #424
1 parent e97eafe commit b13e9ee

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <elrodc@gmail.com>"]
4-
version = "0.12.123"
4+
version = "0.12.124"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/modeling/graphs.jl

+10-5
Original file line numberDiff line numberDiff line change
@@ -1646,12 +1646,17 @@ function Base.push!(
16461646
@assert length(localbody.args) == 2
16471647
LHS = (localbody.args[1])::Symbol
16481648
RHS_1 = localbody.args[2]
1649-
RHS_1 isa Symbol && return push!(ls, localbody, elementbytes, position, mpref)
1650-
RHS = push!(ls, RHS_1, elementbytes, position, mpref)
1651-
if isstore(RHS)
1652-
RHS
1649+
if RHS_1 isa Symbol
1650+
return push!(ls, localbody, elementbytes, position, mpref)
1651+
elseif Meta.isexpr(RHS_1, :(=), 2)
1652+
RHS = push!(ls, RHS_1, elementbytes, position, mpref)
1653+
if isstore(RHS)
1654+
RHS
1655+
else
1656+
add_compute!(ls, LHS, :identity, [RHS], elementbytes)
1657+
end
16531658
else
1654-
add_compute!(ls, LHS, :identity, [RHS], elementbytes)
1659+
push!(ls, localbody, elementbytes, position, mpref)
16551660
end
16561661
else
16571662
throw(LoopError("Don't know how to handle expression.", ex))

test/ifelsemasks.jl

+10
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,15 @@ T = Float32
506506
end
507507
minval, indmin
508508
end
509+
function extrema_turbo(x)
510+
a = b = first(x)
511+
@turbo for i in eachindex(x)
512+
local e = x[i]
513+
b = max(b, e)
514+
a = min(a, e)
515+
end
516+
a, b
517+
end
509518

510519
N = 117
511520
for T (Float32, Float64, Int32, Int64)
@@ -536,6 +545,7 @@ T = Float32
536545
c1 = similar(a)
537546
c2 = similar(a)
538547

548+
@test extrema(a) == extrema_turbo(a)
539549
promote_bool_store!(c1, a, b)
540550
promote_bool_storeavx!(c2, a, b)
541551
@test c1 == c2

0 commit comments

Comments
 (0)