Skip to content

Commit 3fa854d

Browse files
committed
Fix an op undef error and add test
1 parent 7e21d88 commit 3fa854d

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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 <[email protected]>"]
4-
version = "0.12.46"
4+
version = "0.12.47"
55

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

src/modeling/graphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ Returns `-1` if not an outerreduction.
14131413
function isouterreduction(ls::LoopSet, op::Operation)
14141414
if isconstant(op) # equivalent to checking if length(loopdependencies(op)) == 0
14151415
instr = op.instruction
1416-
instr == LOOPCONSTANT && return 0
1416+
instr == LOOPCONSTANT && return Core.ifelse(length(loopdependencies(op)) == 0, 0, -1)
14171417
instr.mod === GLOBALCONSTANT && return -1
14181418
ops = operations(ls)
14191419
for or ls.outer_reductions

test/outer_reductions.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,20 @@ function test_awmean(::Type{T}) where {T}
5454
end
5555
end
5656

57+
function not_an_outer_reduct!(r, N::Int, x = 2.0, y= nothing) # there was a bug where this was classified as one
58+
@turbo for i eachindex(r)
59+
acc = y === nothing ? x : r[i]
60+
for n 1:N
61+
acc += 0
62+
end
63+
r[i] = acc
64+
end
65+
r
66+
end
5767
@testset "Outer Reductions" begin
5868
for T [Float32,Float64,Int32,Int64]
5969
test_awmean(T)
6070
end
71+
@test all(==(7.4), not_an_outer_reduct!(Vector{Float64}(undef, 5), 17, 7.4))
6172
end
6273

0 commit comments

Comments
 (0)