Skip to content

Commit 8b9cd1b

Browse files
committed
Don't gensym vars in _avx.
1 parent cf6fbf6 commit 8b9cd1b

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/_avx.jl

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ to_expr(x) = x
1919

2020
#----------------------------------------------------------------------------------------------------
2121

22-
function find_vars_and_gensym!(ex::Expr, vars::Dict{Symbol, Symbol}, ivars::Vector{Symbol})
22+
function find_vars_and_gensym!(ex::Expr, vars::Set{Symbol}, ivars::Vector{Symbol})
2323
if ex.head == :(=) && ex.args[1] isa Symbol
2424
push!(ivars, ex.args[1])
2525
elseif ex.head == :call
@@ -28,35 +28,33 @@ function find_vars_and_gensym!(ex::Expr, vars::Dict{Symbol, Symbol}, ivars::Vect
2828
ex
2929
end
3030

31-
function find_vars_and_gensym!(x::Symbol, vars::Dict{Symbol, Symbol}, ivars::Vector{Symbol})
32-
if (x keys(vars)) && (x ivars)
33-
gx = gensym(x)
34-
push!(vars, x => gx)
35-
gx
31+
function find_vars_and_gensym!(x::Symbol, vars::Set{Symbol}, ivars::Vector{Symbol})
32+
if (x vars) && (x ivars)
33+
push!(vars, x)
34+
x
3635
else
37-
get(vars, x, x)
36+
x
3837
end
3938
end
4039

41-
find_vars_and_gensym!(x, vars::Dict{Symbol, Symbol}, ivars::Vector{Symbol}) = x
40+
find_vars_and_gensym!(x, vars::Set{Symbol}, ivars::Vector{Symbol}) = x
4241

4342
#----------------------------------------------------------------------------------------------------
4443

4544
nt(keys, vals) = NamedTuple{keys, typeof(vals)}(vals)
4645

4746
macro _avx(ex)
48-
D = Dict{Symbol, Symbol}()
47+
D = Set{Symbol}()
4948
ivars = Symbol[]
5049

5150
gex = prewalk(x -> find_vars_and_gensym!(x, D, ivars), ex)
5251

5352
type_ex = to_type(gex)
5453

55-
tvars = Tuple(keys(D))
56-
tgvars = Tuple(values(D))
54+
tvars = Tuple(D)
5755

5856
quote
59-
kwargs = LoopVectorization.nt($(QuoteNode(tgvars)), $(Expr(:tuple, tvars...)))
57+
kwargs = LoopVectorization.nt($(QuoteNode(tvars)), $(Expr(:tuple, tvars...)))
6058
$(Expr(:tuple, tvars...)) = LoopVectorization._avx($(QuoteNode(type_ex)), kwargs)
6159
# LoopVectorization._avx($(QuoteNode(type_ex)), kwargs) # comment out the above line, uncomment this one, and get rid of the `@generated` on _avx to see the function body.
6260
end |> esc

0 commit comments

Comments
 (0)