Related articles |
---|
A doubt in "Compiler Design in C" about constant folding mayur_naik@my-deja.com (1999-07-21) |
Re: A doubt in "Compiler Design in C" about constant folding root@candle.pha.pa.us (1999-07-23) |
Re: A doubt in "Compiler Design in C" about constant folding mah@colorado.edu (ma haibing) (1999-07-23) |
From: | ma haibing <mah@colorado.edu> |
Newsgroups: | comp.compilers |
Date: | 23 Jul 1999 22:25:16 -0400 |
Organization: | Compilers Central |
References: | 99-07-101 |
Keywords: | books, optimize |
mayur_naik@my-deja.com wrote:
> [ 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.
Haibing Ma
Return to the
comp.compilers page.
Search the
comp.compilers archives again.