Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 9, 2022
1 parent f91af26 commit 1b399fe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/new_rewrite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,21 @@ function _rewrite(stack::Expr, expr::Expr)
rhs = if is_mutable
Expr(:call, MA.operate!!, *, arg1, arg2)
else
Expr(:call, MA.operate!!, MA.add_mul, MA.Zero(), arg1, arg2)
Expr(:call, *, arg1, arg2)
end
root = gensym()
push!(stack.args, :($root = $rhs))
for i in 4:length(expr.args)
arg, _ = _rewrite(stack, expr.args[i])
rhs = Expr(:call, MA.operate!!, *, root, arg)
rhs = if is_mutable
Expr(:call, MA.operate!!, *, root, arg)
else
Expr(:call, *, root, arg)
end
root = gensym()
push!(stack.args, :($root = $rhs))
end
return root, true
return root, is_mutable
elseif expr.args[1] == :.+
# .+(args...) => add_mul.(add_mul.(arg1, arg2), arg3)
@assert length(expr.args) > 1
Expand Down

0 comments on commit 1b399fe

Please sign in to comment.