New update to optabs.c for optimizing C op R expressions.

Paul Koning pkoning@equallogic.com
Sat Jun 29 10:45:00 GMT 2002


Excerpt of message (sent 29 June 2002) by Toon Moene:
> L.S.,
> 
> The attached patch shows at least some optimizing behaviour when
> presented with the following source code:
> 
>       COMPLEX FUNCTION CF(C, R)
>       COMPLEX C
>       REAL    R
>       CF = C * R
>       RETURN
>       END
> 
> Please approve.
> 
> [ Normally, four multiplications have to be performed but with this
> patch (and the -ffast-math option) those have been reduced to two. ]
> 
> Note that -ffast-math is overkill here - what we would need is a
> -ffinite-math switch, that indicated that only finite floating point
> math is supported.  g77 then could set this flag by default (due to the
> definition of the Fortran Language).

I'm puzzled that any switch is needed, since your statement about only
two multiplications being needed is mathematically valid, independent
of any "fast math" or other approximation assumptions.

Or is the issue that you're really looking at C*{R,0.0} with the
second operand promoted to copmlex, and you have to test the imaginary
part for being zero?  Same point, though: if it tests as exactly zero,
then even if you emit the extra multiplies, they will only produce
zero results anyway.  Right?

     paul



More information about the Gcc-patches mailing list