This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fast-math optimization question

On Thu, Oct 09, 2014 at 03:55:34PM -0700, Steve Ellcey wrote:
> On Thu, 2014-10-09 at 19:50 +0000, Joseph S. Myers wrote:
> > On Thu, 9 Oct 2014, Steve Ellcey wrote:
> > 
> > > Do you know which pass does the simple
> > > '(float)function((double)float_val)' demotion?  Maybe that would be a
> > > good place to extend things.
> > 
> > convert.c does such transformations.  Maybe the transformations in there 
> > could move to the match-and-simplify infrastructure - convert.c is not a 
> > particularly good place for optimization, and having similar 
> > transformations scattered around (fold-const, convert.c, front ends, SSA 
> > optimizers) isn't helpful; hopefully match-and-simplify will allow some 
> > unification of this sort of optimization.
> I did a quick and dirty experiment with the match-and-simplify branch
> just to get an idea of what it might be like.  The branch built for MIPS
> right out of the box so that was great and I added a couple of rules
> (see below) just to see if it would trigger the optimization I wanted
> and it did.  I was impressed with the match-and-simplify infrastructure,
> it seemed to work quite well.  Will this branch be included in GCC 5.0?

Though, is such optimization desirable even for fast-math?
I mean, in the normal demotion, all that changes compared to original
source is the possibility of double rounding, or, if right now as in glibc
the *f suffixed varaints aren't 0.5ulp precise while double ones are.

If you want to demote a chain of calls, you add roundings in the middle too,
and depending on which function it is and which exact argument, I'd worry
the maximum error would already be not just slightly higher, but significantly
worse.  Even for -ffast-math we want only slightly worse precision, not
significantly worse one.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]