The instructions and examples for cs 640 homework 2, due in fall 2008. The homework covers dataflow analysis for constant propagation in a control flow graph (cfg), showing the algorithm and its application to a given cfg. It also requires transforming two cfgs to single static assignment (ssa) form and renaming variables, as well as transforming the first cfg to ssa form and explaining how it can be used for constant propagation.
Download CS 640 Homework 2: Dataflow Analysis and SSA Form - Prof. Elizabeth White and more Assignments Computer Science in PDF only on Docsity!
CS 640 HW
Fall 2008
Due Oct 6 at classtime
Dataflow analysis can be used to propagate constants in a CFG. Give a dataflow algorithm for this – be sure to provide details regarding the transfer functions (and how they are computed). Show how your algorithm works on CFG1, including the contents of sets after each iteration. I know some this is available in various textbooks, but try to work out the details yourself. a = 2b = 3c = a + bd = a + ab = ae = a + ba = a + 1b = d + fc = 3c = 3f = a + cb = 5b = d + fe = e + 1 e = d + 1 f = e + c
The two CFGs below have been annotated with assignments for variable x. Show where -functions need to be added for SSA form and show the appropriate functions need to be added for SSA form and show the appropriate variable renaming. Once you have done this, show the transformation back to executable code (i.e. no functions).
Transform the CFG from question 1 to SSA. Use Var0 for the ‘initial’ value of variables if variables are used before defined in the code. Explain how the SSA numbering can be used for constant propagation on this code. a b c d e f g h a i x = x = x = x = j a b c d e f g h k i x = x = x =