next up previous
Next: Annexe 1. Up: Final-13-04-2004 Previous: Exercise 9.

Exercise 10.

Consider the following three-address code program fragment where t3 <> 0 is true if and only if t3 is not zero.
L0: s:=0
  i:=0
  n:=10
L1: t1 := a-b
  if t1 = 0 goto L3
L2: t2 := i*4
  s := s+t2
  goto L4
L3: s := s+i
L4: i := i+1
  t3 := n-i
  if t3 <> 0 goto L1
L5: t4 := a-b
  1. Give the control-flow graph of this program.
  2. Identify the back edges and the loops.
  3. Which optimization (among copy propagation, dead-code elimination, common sub-expression elimination, invariant code motion) can be applied to this program? Show the intermediate transformations of the program. Computing the data-flow sets is not required. A brief justification of each transformation will be sufficient.

Answer 10  
\fbox{
\begin{minipage}{13 cm}
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\end{minipage}}




next up previous
Next: Annexe 1. Up: Final-13-04-2004 Previous: Exercise 9.
Marc Moreno Maza
2004-12-02