You are on page 1of 1

Homework 1

1/24/2022

1. Explain why many compiler optimizations focus on (target) loop nests.

2. Give the sketch of an algorithm that detects all “loops” in a control flow graph (CFG).
State (algorithmic) complexity of your algorithm clearly.

3.
(a) Write a simple grammar that defines the set of expressions over numbers
(represented using “num” in the grammar) and the four arithmetic operators: +, -, *
and /.
(b) Show how “2+3/6” can be derived using your grammar.

4. Give the description of a local (basic block wide) register allocation algorithm which is
not based on graph coloring. Show how your algorithm works on a sample code
sequence. Compare it “qualitatively” against graph-coloring based register allocation.

You might also like