



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main points of this exam are: Liveness Analysis, Influence, Design, Modern Optimising, Traditional Serial, Convert Traditional, Automatically Convert, Compiler, Code Run, Machine
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




Marks : 30 Time : 3 hours Instructions:
after code generation but before liveness analysis [1]
b) For the following program, first separate the code into basic blocks, then rearrange the blocks into traces and finally optimise the code by removing redundant jumps. Show each step separately. [5] Start: Statement Jump X Z: Statement Jump A X: Statement Jump Y A: Statement Y: Statement Jump Z (a) breaking into blocks [1] adding jump [1] Start: Statement Jump X Z: Statement Jump A X: Statement Jump Y A: Statement Jump Y Y: Statement Jump Z (b) sequence of statements [1] Start: Statement Jump X X: Statement Jump Y Y: Statement
Jump Z Z: Statement Jump A A: Statement Jump Y (c) removal of redundant jumps [1] retaining of all labels and final jump [1] Start: Statement X: Statement Y: Statement Z: Statement A: Statement Jump Y Question 6: Register Allocation [ 10 marks ] a) Use the iterative liveness analysis algorithm to calculate the livein and liveout sets for each of the following statements in a program, with the initial and final live sets indicated assume livein (succ ( d=a+b+c )) = {d}. Use the statement numbers provided. Show the succ, use, def and pairs of in/out sets. The last calculated in/out pair must be identical to the previous pair to indicate convergence. [6] [livein: a, b] 1: if (a<b) 2: then c = a; 3: else c = b; 4: d = a + b + c; [liveout: d] Hint: The relevant formula can be stated as follows: out[n] = union of in[s] for all successors s of n in[n] = union of use[n] and (out[n] – def[n]) Iteration 1 Iteration 2 Succ Use Def In Out In Out In:a,b If (a<b) 2,3 ab ab ab ab ab Then c = a 4 a c ab abc ab abc Else c = b 4 b c ab abc ab abc d = a+b+c abc d abc d abc d Out: d Succ [1], Use [1], Def [1], In [1], Out [1], last two iterations being equal [1]
This makes a and b of <K degree, so they can be simplified. [1] Popping the nodes off the stack, we can then assign: [1] A: R B: R C and D: R