egraphs-good / eggcc

MIT License
42 stars 8 forks source link

Add some basic peepholes #523

Closed ezrosent closed 4 months ago

ezrosent commented 4 months ago

This change starts a basic peephole optimization files. Most moderately complex peepholes I've found rely on things like shifting operators, sign extensions, etc. None of those can be done at the bril level (but note that LLVM will take advantage of them with optimizations turned on!)

Still, these probably don't hurt. I've added in some rules for forwarding predicates for ifs. Let me know if I'm using contexts correctly here.

ezrosent commented 4 months ago

Done! I think these ones do saturate but in general peepholes may not. Also optimizations is a better description of what the goal is.

ezrosent commented 4 months ago

Looks like there's a failing test: loop_invariant::test_invariant_detect

I'll take a look