Re: Constant expression evaluation?

david lindauer <>
29 May 2003 03:24:44 -0400

          From comp.compilers

Related articles
Constant expression evaluation? (Paul Davis) (2003-05-14)
Re: Constant expression evaluation? (Christian Bau) (2003-05-16)
Re: Constant expression evaluation? (Dierk Ohlerich) (2003-05-16)
Re: Constant expression evaluation? (Clint Olsen) (2003-05-18)
Re: Constant expression evaluation? (Niksa Orlic) (2003-05-29)
Re: Constant expression evaluation? (david lindauer) (2003-05-29)
| List of all articles for this month |

From: david lindauer <>
Newsgroups: comp.compilers
Date: 29 May 2003 03:24:44 -0400
References: 03-05-089
Keywords: optimize
Posted-Date: 29 May 2003 03:24:44 EDT

Paul Davis wrote:

> I'm hoping to add constant expressions to a simple compiler I've
> written, but it looks like some of my early design decisions will make
> this difficult. I'd appreciate some ideas on better ways to do this.

My own compiler has a constant-expression evaluator... it just goes
through the intermediate parse-trees after the fact of generating them
and evaluates constant expressions before generating code. It works
well, but is kind of inefficient. A really cool thing I found out
from someone on this group is that if you generate say a three-address
intermediate code from the parse trees or whatever, and compile all
the variable references into a DAG tree, you can then evaluate
constant expressions on the fly as you are building the DAG tree.
Much more efficient than the present examination algorithm and gets me
local optimizations at the same time :).


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.