Cheat sheets

CD-17Cheat sheet1 pageIn a paid pack

Basic Blocks, Flow Graphs and Loops

The leader rules and the partition of three-address code into basic blocks, flow-graph edges for fall-through and jumps, dominators, back edges and natural loops, worked on a ten-line loop that is drawn as a flow graph. Two solved past questions count blocks and the largest block, and the traps about jump lines versus jump targets. Every leader, edge and loop comes from a script.

Diagrams from CD-17

CD-18Cheat sheet1 pageIn a paid pack

Block DAGs and Local Optimisation

The DAG of a basic block built by value numbering, drawn for a classic block and used for local common-subexpression and dead-code elimination. The local rewrites (constant folding and propagation, copy propagation, algebraic identities, strength reduction, dead code) applied in sequence to one block with a script check that the live results never change, peephole rules, and register and temporary counts: Ershov labels for an expression tree and the maximum number of live values in a straight-line block.

Diagrams from CD-18