This demo pr add some in-place simplify of Expression and can collapse some certain case expressions.
The simplification is best-effort, it cannot simplify to the simplest representation since it's a undecidable problem. And it's not worth to simplify it to simplest since it MUST introduce more cost.
Especially the case of rw_counter_offset, every lookup with condition will cause it adds the condition expo to rw_counter_offset, like:
This demo pr add some in-place simplify of
Expression
and can collapse some certain case expressions. The simplification is best-effort, it cannot simplify to the simplest representation since it's a undecidable problem. And it's not worth to simplify it to simplest since it MUST introduce more cost.Especially the case of rw_counter_offset, every lookup with condition will cause it adds the condition expo to rw_counter_offset, like:
by apply following rule, it can fold expressions like that:
poly + poly == 2 * poly
(poly + poly1) + poly = poly * 2 + poly1
a * poly + poly = (a + 1) * poly
introduce complex (this one is not that complex) optimisation to basic building blocks which code usually don't change could be ok