curiousdannii / if-decompiler

Decompile Glulx storyfiles into C code
MIT License
17 stars 0 forks source link

Optimisation: if a loop has no next edge pull one non-scc node out #5

Open curiousdannii opened 3 years ago

curiousdannii commented 3 years ago

Currently nodes that are not part of a loop scc are not pulled out (ie, made a next edge) unless they are not dominated by the loop header. This means that a series of loops becomes deeply nested. As most loops have only one exit node, we can put it out as long as there isn't already a next edge. We could simply pull the first non-scc node out, or try to weigh the options somehow.

curiousdannii commented 3 years ago

I removed the code that did this as it was unsafe - it didn't account for descendent nodes that had merged branches. As this is only a cosmetic optimisation (reducing nested code) I won't try to implement it for now.