You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We desugar code like (rewrite (Add x y) (Add y x)) into something like:
(rule ((= e (Add x y))) ((union (Add y x) e)))
But using union is only needed if the right-hand side of a rewrite is an identifier. When it's an expression, we could do:
(rule ((= e (Add x y))) ((set (Add y x) e)))
This should be safe, but it gives egglog less work to do: if (Add y x) is in the database already, setting it will call union anyway as part of the merge process. If it isn't we skip creating a new noncanonical id that rebuilding has to clean up.
On the following program, this is a significant speedup:
Unfortunately using set on datatypes is going to be disallowed with the semantics we decided on recently.
Perhaps query compilation can recognize this optimization later in the pipeline?
We desugar code like
(rewrite (Add x y) (Add y x))
into something like:But using
union
is only needed if the right-hand side of a rewrite is an identifier. When it's an expression, we could do:This should be safe, but it gives egglog less work to do: if
(Add y x)
is in the database already, setting it will call union anyway as part of the merge process. If it isn't we skip creating a new noncanonical id that rebuilding has to clean up.On the following program, this is a significant speedup:
This program takes 22.5 seconds to saturate on my machine. The usual rules for associativity and commutativity take 29s.
The text was updated successfully, but these errors were encountered: