Example .

Code for while a < b do
if c < d then
x = y + z
else
x = y - z
L1 : if a < b goto L2 //no jump to L2 if a>=b. next instruction causes jump outside the loop
goto L.next
L2 : if c < d goto L3
goto L4
L3 : t1 = Y + Z
X= t1
goto L1 //return to the expression code for the while loop
L4 : t1 = Y - Z
X= t1
goto L1 //return to the expression code for the while loop
L.next:
Here too the first two goto statements can be eliminated by changing the direction of the tests (by translating a relational expression of the form id1 < id2 into the statement if id1 id2 goto E.false).
|