[RFC] Expanders for lround

Richard Guenther rguenther@suse.de
Thu Dec 22 19:35:00 GMT 2005


On Thu, 22 Dec 2005, Andrew Pinski wrote:

> 
> On Dec 22, 2005, at 8:01 AM, Richard Guenther wrote:
> 
> > Fortran will not benefit from this ATM as it does the x<0?x-0.5:x+0.5
> > expansion itself and does not have lround defined nor is (int)round
> > converted to that (because this transformation is still in convert.c).
> > But I have patches to make it generate calls to lround directly
> > instead - which I like to replace with proper FIX_ROUND_EXPR as
> > fortran does not care about errno.
> 
> Fortran already sets flag_errno_math which is the same thing

Sure, still FIX_ROUND_EXPR may be a better choice - but this is why
I asked before starting to re-do the patch ;)

> > Comments?  Bootstrapped & regtested on x86_64-unknown-linux-gnu.
> 
> What about also trying the round optab and then using that instead of
> "x<0?x-0.5:x+0.5"?

Using the round optab will be slower with SSE.  Otherwise, in general
you are right.

> Also don't you need to check in some way or another flag_errno_math?

Yes, I would need to handle possible EDOM.  This raises the question
what to do about (long)round(x), which will not set errno, but is
translated to lround(x) in convert.c which may set errno.  Either we
need to disable this transformation if flag_errno_math is set, or
ignore errno setting in expanding of lround, or somehow mark the call
as not supposed to set errno.

Richard.

> 
> Thanks,
> Andrew Pinski
> 
> 



More information about the Gcc-patches mailing list