egraphs-good / eggcc

MIT License
42 stars 8 forks source link

[Tree in context] Add CICM rules #381

Closed rtjoa closed 6 months ago

rtjoa commented 7 months ago

Performs the CICM rules version in previous encodings, which perform rewrites like the following (arg types elided for brevity):

(Switch (Const (Int 1)) '(
  (Bop (LessThan) (Get (Arg ...) 0) (Const (Int 7)))
  (Bop (LessThan) (Get (Arg ...) 1) (Const (Int 7)))))

~~>

(Bop (LessThan)
  (Switch (Const (Int 1)) '(
    (Get (Arg ...) 0)
    (Get (Arg ...) 1)))
  (Const (Int 7)))

We'll eventually want to handle more complicated examples that require us to "reach through" lets.

rtjoa commented 6 months ago

Nice work- are you going to make this code work for If as well?

Thanks for the review. Will follow up with this!