[PATCH v3] Change default to -fno-math-errno

Richard Biener richard.guenther@gmail.com
Thu Oct 4 12:46:00 GMT 2018


On Thu, Oct 4, 2018 at 2:06 PM Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Thu, 4 Oct 2018, Richard Biener wrote:
>
> > The other issue is that we're treating -fno-math-errno as disabling
> > errno handling in general (not only for math functions).  That would
>
> Also, is it treated as meaning the math functions *do not set errno* (so a
> load of errno (or of anything that might be errno) before a math function
> call could be moved after the call)?

Yes.  That's implicit in math functions becoming CONST.

>  Because the proper meaning is simply
> *may not set errno* (so you shouldn't be able to move an errno load across
> a call like that, since the call might still happen to clobber it - of
> course if it happens to be a call that GCC inlines and eliminates any
> possibility of errno setting that way, e.g. sqrt on many platforms, or a
> platform where libm never sets errno at all, then such a move is safe).

So it means that GCC may elide errno setting (by inlining a function
for example)
but otherwise assume nothing else?  That makes it quite useless to optimizers.
For example the vectorizer would need to know pow() doesn't clobber
random memory
and thus causes dependency issues.  It's of course also inconsistent with
the fact that we make those math functions CONST with -fno-math-errno.

I see that the user documentation suggests what you say but I'll note that
implementation-wise we've done what I explained for a long time now.

Richard.

> --
> Joseph S. Myers
> joseph@codesourcery.com



More information about the Gcc-patches mailing list