Skip to content

Commit fb9b868

Browse files
committed
Fix UndefVarError in previously untested code path, fixes #292.
1 parent 82ce267 commit fb9b868

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/codegen/loopstartstopmanager.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ function cse_constant_offsets!(
366366
Expr(:call, GlobalRef(Base,:(-)), gespsymbol, name(op2))
367367
end
368368
gespsymbol = gensym!(ls, "#gespsym#")
369-
push!(q.args, Expr(:(=), gespsymbol, subexpr))
369+
pushpreamble!(ls, Expr(:(=), gespsymbol, subexpr))
370370
ind = maybeloopvaluename(op1)
371371
substitute_ops_all!(ls, i, ii, indop, op1, allarrayrefs, array_refs_with_same_name, arrayref_to_name_op_collection)
372372
else

test/copy.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,15 @@ using LoopVectorization, OffsetArrays, Test
266266
issue280!(dest2, src2)
267267
@test dest2 vcat(view(src,2,:)',view(src,1,:)')
268268
end
269+
270+
rng = 10:20
271+
arr1 = zeros(30);
272+
arr2 = zeros(30);
273+
ifirst = 5
274+
@turbo for i in rng
275+
arr1[i-ifirst] += 1
276+
end
277+
@. arr2[rng-ifirst] += 1;
278+
@test arr1 == arr2
269279
end
270280
end

0 commit comments

Comments
 (0)