Re: non trivial constant folding

Robert Metzger <metzger@rsn.hp.com>
9 Jan 2001 23:13:21 -0500

          From comp.compilers

Related articles
[3 earlier articles]
Re: non trivial constant folding pat@jantar.org (Patryk Zadarnowski) (2001-01-06)
Re: non trivial constant folding bonzini@gnu.org (2001-01-06)
Re: non trivial constant folding idbaxter@semdesigns.com (Ira D. Baxter) (2001-01-06)
Re: non trivial constant folding cfc@world.std.com (Chris F Clark) (2001-01-06)
Re: non trivial constant folding anton@mips.complang.tuwien.ac.at (2001-01-09)
Re: non trivial constant folding anton@mips.complang.tuwien.ac.at (2001-01-09)
Re: non trivial constant folding metzger@rsn.hp.com (Robert Metzger) (2001-01-09)
Re: non trivial constant folding sjmeyer@www.tdl.com (2001-01-09)
Re: non trivial constant folding henry@spsystems.net (2001-01-09)
Re: non trivial constant folding dew@cray.com (2001-01-09)
Re: non trivial constant folding mpointie@eden-studios.fr (Mickaël Pointier) (2001-01-09)
Re: non trivial constant folding morrell@morrell.cup.hp.com (Michael Morrell) (2001-01-09)
Re: non trivial constant folding dmr@bell-labs.com (Dennis Ritchie) (2001-01-11)
[7 later articles]
| List of all articles for this month |
From: Robert Metzger <metzger@rsn.hp.com>
Newsgroups: comp.compilers
Date: 9 Jan 2001 23:13:21 -0500
Organization: Compilers Central
References: 01-01-015
Keywords: arithmetic, optimize
Posted-Date: 09 Jan 2001 23:13:21 EST

On 5 Jan 2001, Mickaël Pointier wrote:


> My problem is that I do not manage to find a clean solution
> to optimise this:
>
> eval(1+var+1)
>
> [I've seen compilers that do that. With associative operators like +
> they combine all of the operands of a set of cascaded operators into
> a list or array, then sort that array to get the constants together.
> -John]


You will find several methods to convert expressions to a canonical form,
which includes your example as a special case, in Chapter 6
"Converting to a Canonical Form" in
Automatic Algorithm Recognition and Replacement:
A New Approach to Program Optimization,
R. Metzger and Z. Wen, MIT Press, 2000.


---------------------------------------------------------------------------
Robert Metzger | TEL (972) 497-4437 | 3000 Waterview Parkway
Technical Solutions Lab | FAX (972) 497-4245 | P.O. Box 833851
Hewlett-Packard Company | metzger@rsn.hp.com | Richardson, TX 75080-3851


Post a followup to this message

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