Talk:Partial redundancy elimination

From Wikipedia, the free encyclopedia

Why such a strange result, doubling the code size? Won't it better look so:

 t = x + 4;
 if (some_condition) {
   // some code
   y = t;
 }
 else {
   // other code
 }
 z = t;
(please, sign your comments by adding 4 ~'s at the end). The point of this optimization is not to reduce code size but execution time. I.e., to prevent "x+4" from being calculated twice. (Anyway, the code size doesn't get doubled). Note that instead of "x+4" we could have a more time-consuming expression, e.g., some floating point division, or even a whole expression formed by many operators (e.g., "x*pi/180. + 3.2"). Your proposal only works in case the inner code didn't modify "x"'s value, but it would certainly be reached by a CSE optimizer should that be the case, without need of partial redundancy elimination. --euyyn 13:54, 18 June 2006 (UTC)


Imagine there is more than two paths - would we add x+4 calculation to every of paths ?

That's what is proposed. Of course, in extremis, code size can handicap execution speed, due to cache faults, but I don't think this optimization could realistically reach that point. I've not read anymore about the subject than this article, so I don't know how the authors dealed with this, nor if anyone else has. --euyyn 13:54, 18 June 2006 (UTC)