A list of compiler optimizations with descriptions and code snippets.
The entries are concise, clear, and with short, easy to understand snippets. A great example of algorithm documentation.
A list of compiler optimizations with descriptions and code snippets.
The entries are concise, clear, and with short, easy to understand snippets. A great example of algorithm documentation.
@amoroso For every complex problem there is an answer that is clear, simple, and wrong. You can’t implement much with informal source-level descriptions. Take:
“In the code fragment below, the body of the loop can be replicated once and the number of iterations can be reduced from 100 to 50.”
for (i = 0; i < 100; i++)
g ();
First off, what’s a loop? It’s sensible to turn everything into basic blocks, which doesn’t expose loops anymore. (Better get a loop finding algorithm.) Now how do I copy and glue the loop body after itself? What happens to i, do I still have to check that 100 times? (To get i += 2 and only 50 tests of i < 100 I need to spot induction variables which control the loop, or some other way to tell that the second body won’t exit the loop.) Or:
“Loop-invariant expressions can be hoisted out of loops”
So they can, but what’s the algorithm to spot loop invariance? To no surprise the answers to my questions would mostly be “it depends on the data structures.”