Re: non trivial constant folding

henry@spsystems.net (Henry Spencer)
9 Jan 2001 23:14:52 -0500

          From comp.compilers

Related articles
[5 earlier articles]
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)
Re: non trivial constant folding ONeillCJ@logica.com (Conor O'Neill) (2001-01-11)
Re: non trivial constant folding sjmeyer@www.tdl.com (2001-01-18)
[5 later articles]
| List of all articles for this month |

From: henry@spsystems.net (Henry Spencer)
Newsgroups: comp.compilers
Date: 9 Jan 2001 23:14:52 -0500
Organization: SP Systems, Toronto, Canada
References: 01-01-015 01-01-022
Keywords: optimize
Posted-Date: 09 Jan 2001 23:14:52 EST

Mihai Christodorescu <mihai@cs.wisc.edu> wrote:
> There is also another problem: the optimized expression can behave
>differently than the original expression, due to operations being executed
>in different order/with different operands. Consider:
> "MAXINT + x - 1"
>If x is 1, then evaluating MAXINT + x will overflow.


As our moderator has already noted, whether changing exception
behavior is actually *wrong* depends on the definition of the
language. A number of languages say that the result in such a case is
ill-defined -- that whether or not it causes an exception is not
predictable, because left-to-right evaluation is not guaranteed.


Of course, there is a practical issue to contend with: users who do
not understand the language specification well enough to realize this.
They may still complain.


>...Of course, these are contrived examples, but a
>compiler has to work for all cases, not most of the time...


Except when the language spec says it doesn't have to.
--
When failure is not an option, success | Henry Spencer henry@spsystems.net
can get expensive. -- Peter Stibrany | (aka henry@zoo.toronto.edu)


Post a followup to this message

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