egraphs-good / eggcc

MIT License
42 stars 8 forks source link

[TreeUnique] IVT #268

Closed ezrosent closed 8 months ago

ezrosent commented 8 months ago

This is my attempt at #244

The rules are a lot simpler than in the milestone encoding. That's due to the encoding itself being easier to write rules for, and also because the rule itself only matches loops whose body is "just a switch." I think we want to have rules that push computations inside switches in order to expose opportunities to IVT (we already have some of these).

Marking this as a draft as I'm not sure about the best way to re-assign expressions' ids (e.g. within Nums) to ids from the outer scope. The test gives an example (see the TODO) of a case where the Nums retain the id from the old loop. I figure this is something that's come up before and I'd appreciate guidance on on the cleanest way to do it.

ezrosent commented 8 months ago

Thanks for the review! And let me know if I didn't understand your comment correctly; happy to send a follow-up if there are more ways to improve here.