@@ -19,7 +19,7 @@ to_expr(x) = x
19
19
20
20
# ----------------------------------------------------------------------------------------------------
21
21
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} )
23
23
if ex. head == :(= ) && ex. args[1 ] isa Symbol
24
24
push! (ivars, ex. args[1 ])
25
25
elseif ex. head == :call
@@ -28,35 +28,33 @@ function find_vars_and_gensym!(ex::Expr, vars::Dict{Symbol, Symbol}, ivars::Vect
28
28
ex
29
29
end
30
30
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
36
35
else
37
- get (vars, x, x)
36
+ x
38
37
end
39
38
end
40
39
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
42
41
43
42
# ----------------------------------------------------------------------------------------------------
44
43
45
44
nt (keys, vals) = NamedTuple {keys, typeof(vals)} (vals)
46
45
47
46
macro _avx (ex)
48
- D = Dict {Symbol, Symbol} ()
47
+ D = Set { Symbol} ()
49
48
ivars = Symbol[]
50
49
51
50
gex = prewalk (x -> find_vars_and_gensym! (x, D, ivars), ex)
52
51
53
52
type_ex = to_type (gex)
54
53
55
- tvars = Tuple (keys (D))
56
- tgvars = Tuple (values (D))
54
+ tvars = Tuple (D)
57
55
58
56
quote
59
- kwargs = LoopVectorization. nt ($ (QuoteNode (tgvars )), $ (Expr (:tuple , tvars... )))
57
+ kwargs = LoopVectorization. nt ($ (QuoteNode (tvars )), $ (Expr (:tuple , tvars... )))
60
58
$ (Expr (:tuple , tvars... )) = LoopVectorization. _avx ($ (QuoteNode (type_ex)), kwargs)
61
59
# 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.
62
60
end |> esc
0 commit comments