next up previous
Next: Exercise 2. Up: Quiz8 Previous: Guidelines.

Exercise 1.

Consider the following three-address code fragment.
L0 a := 15
  b := 12
L1 if b = 0 goto L6
L2 q := 0
  r := a
L3 if r < b goto L5
L4 r := r - b
  q := q + 1
  goto L3
L5 a := b
  b := r
  goto L1
L6 g := a
  1. Give the flow graph of this program.
  2. Identify the back edges and the loops.
  3. Is there any propagation of a copy statement that can be performed. Justify your answer briefly.
  4. Explain how the techniques developed in the course can help discover that two lines of the above program can be eliminated.

Answer 1  
% latex2html id marker 341
\fbox{
\begin{minipage}{14 cm}
The node $B_1$\ in the...
...that can be eliminated.
Then {\tt q := 0} becomes dead-code too.
\end{minipage}}

Figure 1: The control flow graph.
\begin{figure}\htmlimage
\centering\includegraphics[scale=.35]{ControlFlowGraph10.eps}
.
\end{figure}


next up previous
Next: Exercise 2. Up: Quiz8 Previous: Guidelines.
Marc Moreno Maza
2004-12-02