Optimize value-producing assembly #262
-
Hi, I've been looking into egg recently to help optimize a simple assembly language that produces values into registers. The thing I want to start with is using registers optimally: there are 4 registers and current assembly generation only uses one. So I want to go from
To
Is this something I can do using egg at all? I did an implementation doing graph coloring to allocate registers and re-use already computed values, but this is only one of the many optimizations I would like to do and the part where I don't have to think about what order to apply optimizations in and maintain all the equivalent representations sounds really interesting to me. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I do not think that register allocation is a problem well-suited to e-graphs; you don't want to be representing all possible ways to allocate registers. However, if you plan on doing some other kind of optimization in the e-graph, it's certainly possible to do things "outside" the e-graph and cooperate with those optimizations. For example, you might do a little optimization in the e-graph, extract some version of the program and do register coloring on that, and then re-insert that into the e-graph. I would also advise you that sequential instructions are not the friendliest representation for e-graphs; it is typically better to do some kind of conversion to dataflow first. |
Beta Was this translation helpful? Give feedback.
I do not think that register allocation is a problem well-suited to e-graphs; you don't want to be representing all possible ways to allocate registers. However, if you plan on doing some other kind of optimization in the e-graph, it's certainly possible to do things "outside" the e-graph and cooperate with those optimizations. For example, you might do a little optimization in the e-graph, extract some version of the program and do register coloring on that, and then re-insert that into the e-graph. I would also advise you that sequential instructions are not the friendliest representation for e-graphs; it is typically better to do some kind of conversion to dataflow first.