Final Exam, Part I

advertisement
CSCE 5650 Final Exam --- Part 1
To complete this portion of the final exam, you are free to use written or online material
other than something specifically requested for this exam. You are NOT to discuss this
exam with any human other than myself --- and I won’t be much help.
Consider the following control flow graph:
i=0
a=0
B1
b=3
B2
X=a+1
B3
B4
c=a+2
c=b+5
b=a+2
B5 d = a + b
B7
B6
B8
c=c+1
d=a+c
B9
c=a -c
a=a+1
i=i+1
B10
X=a+b+c+d
return
i=i+1
In the above control-flow graph, X is a global variable. All other variables listed should be
considered local variables. (In this context, local means within the function represented by
the control flow graph. Global means the variable has program scope.)
Complete the following:
1. Show the Dominator Tree.
2. Show the Post-Dominator Tree.
3. List the dominator frontier for each basic block of the CFG.
4. Insert the (non-minimal) phi-nodes inserted by the simple algorithm of Morgan.
5. Show the minimal phi-nodes. (Feel free to cross out unnecessary phi-nodes from the
previous step to show the minimal set.)
6. Show the final SSA form of the CFG after renaming.
7. Do simple optimizations to the SSA form of the CFG. (I don’t care about what or
how many optimizations you do as long as you remove at least two statements in your
“optimization” phase.
8. Convert the SSA form back to the “equivalent” control-flow graph form.
Download