This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Simplify floating point conversions
> Jan Hubicka <jh@suse.cz> writes:
>
> > Hi,
> > this patch makes us to simplify some of the floating point operations to
> > narrower mode when conversions are present. This include
> > +,-,/,*,abs,neg,sqrt/sin/cos/exp.
> > I believe it is IEEE safe, but some expert would be welcome.
>
> It's not safe, except for 'abs' and 'neg'. For example,
> (float)sqrt(2.0 * FLT_MAX) != sqrtf(2.0 * FLT_MAX).
> I think it would be OK for -ffast-math, though.
I am doing only (float)sqrt((double)float)
that commonly results from C code that uses floats but calls math
functions. I can add fast-math code for weaker checks later, but first
I would like to know whether this transformation is valid.
I will add the comments :) I usually write the automatically and
ididn't noticed there are none..
Honza
>
> --
> - Geoffrey Keating <geoffk@geoffk.org>