This is the mail archive of the gcc-patches@gcc.gnu.org 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: [PATCH v3] Change default to -fno-math-errno


Hi,
  
> if (math_errhandling & MATH_ERRNO) == 0 a math
> function may still set errno.
>
> it can only set it if there was an error though,
> not arbitrarily clobber it, but this means that
>
> (1) reordering errno access around math calls is
> invalid even with -fno-math-errno.

It's typically the math calls themselves which are optimized, moved, CSEd etc.
However if a compiler has to optimize based on the assumuption that math
calls may still set errno then no optimizations are feasible.

> (2) user code reading errno after a math call can
> assume it to be unmodified in exactly the same
> cases with -fmath-errno and -fno-math-errno.

Again, that would mean there cannot be any difference in code generation
(which blocks all optimization).

To optimize math calls you really need to assume they are const and don't
write errno. This can be done by ensuring the library never sets errno for math
functions or simply ignore the low probability that an optimized math call might
corrupt a non-math use of errno (like GCC already does today for many math
functions, even with -fmath-errno).

Wilco
    

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