|A doubt in "Compiler Design in C" about constant folding email@example.com (1999-07-21)|
|Re: A doubt in "Compiler Design in C" about constant folding firstname.lastname@example.org (1999-07-23)|
|Re: A doubt in "Compiler Design in C" about constant folding email@example.com (ma haibing) (1999-07-23)|
|From:||ma haibing <firstname.lastname@example.org>|
|Date:||23 Jul 1999 22:25:16 -0400|
> [ In the book "Compiler Design in C" by Allen I. Holub, why doesn't he
> do constant folding of logical ops? ]
Here's my thought.
Logical operators are different from arithmetic operators. Logical
operators are so called "short circuited", they are actually
translated into a sequence of condjump/jump instructions. So you
cannot do the constant folding in the way of arithmetic operators.
> [Useful constant folding here also involves dead code elimination, since
> the "if" statement turns into if(0), the goto T1 disappears, making T1
> unreachable so X1 := 1 disappears, making the goto E1 redundant. Perhaps
> he didn't want to go into all that. -John]
I agree with John. Optimization methods are much more complicated.
Translating into a correct sequence of jumps is the main issue here.
Doing (combined) anlysis on constant folding and dead code elimination
is a different story here.
Return to the
Search the comp.compilers archives again.