1. Trace optimisation cannot be performed on non-canonicalised trees. Why not? [2] 2. Answer questions 8.1 and 8.2 of Appel. 3. Break the following straight-line program into basic blocks and then generate a set of traces. a = 0 b = 0 lab1: compare a and 10 jump on lt to lab2, gte to lab3 lab2: jump lab4 lab3: jump lab9 lab4: c = a div 3 compare c and 0 jump on eq to lab5, ne to lab6 lab5: jump lab7 lab6: jump lab8 lab7: b = b + a lab8: a = a + 1 jump lab1 lab9: (for the curious: (1) this calculates the sum of all multiple of 3 in the range 0-9 (2) the mini jump-tables seem spurious but do remember that many machine code dialects - like 80*86/Pentium - have conditional jump instructions with a limited range. this would also place restrictions on trace optimisation, but we will ignore those for these problems) 4. Similarly, answer question 8.6 of Appel. Then generate a set of traces for those basic blocks. 5. Discuss the maximal munch algorithm. What is its algorithmic efficiency (space vs. nodes and time vs. nodes)? Is it optimal or optimum? 6. Discuss the dynamic programming approach to instruction tiling. What is its algorithmic efficiency (space vs. nodes and time vs. nodes)? Is it optimal or optimum? 7. Answer question 9.1 using both MM and DP. 8. What is liveness analysis? Why do we need it when generating code? 9. Use the iterative liveness analysis algorithm to calculate the live-in and live-out sets for each of the following statements in a program, with the initial and final live sets indicated - assume live-in (succ ( b=c+d+e )) = {b,c,e}. [live-in: {}] a = 5 b = a c = 10 d = 20 e = c + d + a b = c + d + e [live-out: {b,c,e}] 10. Suppose we have the following interference graph (which, btw, is more or less derived from the solution to 9): a . | \ . | \ b----c----d \ | / \ | / e Calculate the register allocation by 3-colouring the graph, given that a is precoloured and {a,b} are related by a MOVE. Name your registers r1 (=a), r2 and r3. a) use aggressive coalescing b) Use George's conservative coalescing c) Use Briggs' conservative coalescing