John McEnerney (johnmce@world.std.com) wrote:: I'm implementing the Copy Propagation optimization as described in the: new Dragon Book, pp. 636-638, and I've run into an interesting problem: motivated by the following case:

: y=x; z=y; x=3; w=z+100;

: The dataflow computation tells me that I can propagate 'x' to 'z=y', and: that I can propagate 'y' to 'w=z+100', but obviously I can't eliminate: both 'y=x' and 'z=y' because of the assignment to x. So I can choose one: or the other:

: z=x; x=3; w=z+100; -OR- y=x; x=3; w=y+100;

Your problem is that you try to propagate variables and not the values they
contain. So if you write your original source code as follows :

y_0=x_0; z_0=y_0; x_1=3; w_0=z_0+100;

where the `_n' notation is meant to differentiate among the values
each of the variables contains, then everything works out fine :

y_0 = x_0 = z_0
x_1 = 3
w_0 = x_0 + 100

BTW : what is the new Dragon book ? I see references to this book in this
newsgroup once in a while and I suppose the book is named like that because
of some cover drawing, but I suppose it also has an offical title, no ?

Joris.
[The new dragon book is the 1986 edition of Aho, Sethi, and Ullman. See the
FAQ. There's a dragon on the cover. -John]
--