Talk:Common subexpression elimination

From Wikipedia, the free encyclopedia

Hello!

I think that there is an error in example. Here is my suggestion how it should be: _______________________

Here is a simple example:

a = b * c + g;
c = b * c * d;
e = b * c;

which does four multiplies and one addition, can be replaced by

tmp = b * c;
a = tmp + g;
c = tmp * d;
e = b * c; 

which does three multiplies and one add.

Variable "e" can't be replaced with "tmp", because in third line value of "c" is changed - so value of "tmp" is not correct anymore (out-of-date). We have to recalculate value of "tmp" or let this (4th) line well alone (no substitution).

______________________

English is not my native language, so I didn't correct the page, beacause of possible language mistakes...

PS: Maybe I'm wrong about this error?

Mirek [PL]

Ooops! I'll fix it. Stan 22:12, 22 May 2004 (UTC)