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] Implement "atan" builtin as x87 intrinsic


On 15 Jun 2003, Gabriel Dos Reis wrote:
> Roger Sayle <roger@eyesopen.com> writes:
> | Secondly, it tweaks the way that we specify whether built-in
> | mathematical functions may set errno or not in builtins.c.  We now
> | default to false, and each function that may set errno is responsible
> | for flagging this explicitly.
>
> Why this change in the default?  I would rather see the default the
> other way around.  One day or the other someone will forget to set
> things properly.

The most obvious motivation for changing the default is that we
currently have more mathematical functions that don't set errno
than we have functions that do.

Indeed this patch fixes a problem where "someone forgot to set
things properly".  The "sin" and "cos" functions were not setting
errno_set to false, even though they don't modify errno.  This means
in some circumstances, i.e. "-funsafe-math-optimizations" but not
"-ffast-math", we'd generate unnecessary code that tested whether
the result of the sin/cos intrinsic was NaN and called the system
library function instead.

I apologise for not mentioning this in my previous post.  This patch
has been waiting for over a month on my "exp" instrinsic patch to
be reviewed, so I'd forgotten the bug-fix until you asked.

Finally, this shift of responsibility for each builtin to handle
setting errno_set itself allows for additional built-in specific
optimizations.  For example, sqrt(x*x+y*y) can never set errno
because its argument is never negative.  expand_builtin_mathfn
can take advantage of these situations such that GCC only adds
the additional code to adjust errno when the GCC built-in indicates
that its needed.

Roger
--


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