Skip to content

Commit 0b258bb

Browse files
committed
cse getproperty in add_operation!. Fixes #217
1 parent 8b8f087 commit 0b258bb

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
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.8"
4+
version = "0.12.9"
55

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

src/modeling/graphs.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,13 @@ function add_operation!(
970970
add_if!(ls, LHS, RHS, elementbytes, position)
971971
elseif RHS.head === :block
972972
add_operation!(ls, LHS, strip_op_linenumber_nodes(RHS), elementbytes, position)
973+
elseif RHS.head === :(.)
974+
c = gensym!(ls, "getproperty")
975+
pushpreamble!(ls, Expr(:(=), c, RHS))
976+
add_constant!(ls, c, elementbytes)
977+
# op = add_constant!(ls, c, ls.loopsymbols[1:position], LHS, elementbytes, :numericconstant)
978+
# pushpreamble!(ls, op, c)
979+
# op
973980
else
974981
throw(LoopError("Expression not recognized.", RHS))
975982
end
@@ -1005,6 +1012,13 @@ function add_operation!(
10051012
add_if!(ls, LHS_sym, RHS, elementbytes, position, LHS_ref)
10061013
elseif RHS.head === :block
10071014
add_operation!(ls, LHS, strip_op_linenumber_nodes(RHS), elementbytes, position)
1015+
elseif RHS.head === :(.)
1016+
c = gensym!(ls, "getproperty")
1017+
pushpreamble!(ls, Expr(:(=), c, RHS))
1018+
add_constant!(ls, c, elementbytes)
1019+
# op = add_constant!(ls, c, ls.loopsymbols[1:position], LHS_sym, elementbytes, :numericconstant)
1020+
# pushpreamble!(ls, op, c)
1021+
# op
10081022
else
10091023
throw(LoopError("Expression not recognized.", RHS))
10101024
end

src/parse/add_constants.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ function add_constant!(
5656
ls::LoopSet, value::Symbol, deps::Vector{Symbol}, assignedsym::Symbol, elementbytes::Int, f::Symbol = Symbol("")
5757
)
5858
retop = get(ls.opdict, value, nothing)
59-
if retop !== nothing
60-
op = Operation(length(operations(ls)), assignedsym, elementbytes, :identity, compute, deps, reduceddependencies(retop), [retop])
61-
else
59+
if retop === nothing
6260
op = Operation(length(operations(ls)), assignedsym, elementbytes, Instruction(f, value), constant, deps, NODEPENDENCY, NOPARENTS)
61+
else
62+
op = Operation(length(operations(ls)), assignedsym, elementbytes, :identity, compute, deps, reduceddependencies(retop), [retop])
6363
end
6464
pushop!(ls, op, assignedsym)
6565
end

0 commit comments

Comments
 (0)