Re: Advanced expression simplification

"F. Liekweg" <>
17 Jul 2005 13:58:28 -0400

          From comp.compilers

Related articles
Advanced expression simplification (2005-07-11)
Re: Advanced expression simplification (Marco van de Voort) (2005-07-11)
Re: Advanced expression simplification (2005-07-12)
Re: Advanced expression simplification (Gene) (2005-07-17)
Advanced expression simplification (Evangelos Drikos) (2005-07-17)
Re: Advanced expression simplification (F. Liekweg) (2005-07-17)
| List of all articles for this month |

From: "F. Liekweg" <>
Newsgroups: comp.compilers
Date: 17 Jul 2005 13:58:28 -0400
Organization: University of Karlsruhe, Germany
References: 05-07-040
Keywords: optimize
Posted-Date: 17 Jul 2005 13:58:28 EDT

Truly, Igor Chudov wrote on 07/11/05 13:03:
> (x^2-1)/(x-1) simplifies to x+1. GOOD
> (1^100-1)/(x-1) "simplifies" to x^99+x^98+...+x+1. NOT GOOD.

But watch out, neither case preserves the division-by-zero
condition for x==1. The code around the expression might
actually depend on this behaviour, much like the elimination
of memory stores/loads might omit null-pointer checks that
the surrounding code might depend on.

Also, if you are transforming floating-point expressions,
a seemingly more complicated expresson might be numerically
stable and more robust wrt. rounding errors that the simplified
version. In particular, inside a fixed-point iteration, a longer
expression that is better conditioned might reduce the number
of iterations needed for convergence, so that simplifying it
would be counter-productive.

Florian Liekweg | Dot is a very forgiving language; it should
Universitšt Karlsruhe | be considered some form of religion.
================================= ==

Post a followup to this message

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