This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Converting floor to rint
On Thu, Nov 07, 2002 at 10:21:12AM +0100, Jan Hubicka wrote:
> > | On the related note. How bad would you consider converting
> > | floor(x) into rint(x-0.5) in the fast-math mode?
> >
> > If you think you do want to do that transformation, then I would
> > prefer this
> >
> > floor(x) -> nearbyint(x-0.5)
> >
> > | That transformation would do a miracles for i386, where rint is faster
> > | than floor by quite a lot and should suffice for 3D application in
> > | reliablility. I can imagine it to fail only for very large numbers...
> >
> > Not really. floor(1) == 1 and rint(1 - 0.5) maybe be 0 or 1 depending
> > on the current rounding mode.
> Hmm, is rint really expected to be dependent on the rouding mode?
> Man page claims:
> The nearbyint functions round their argument to an integer value
> in floating point format, using the current
> rounding direction and without raising the inexact
> exception.
>
> The rint functions do the same, but will raise the
> inexact exception when the result differs in value
> from the argument.
>
> I can builtinize nearbyint too if it makes sense. I am bit confused by
> rint. Does it imply that rint will raise exception for any non-integral
> arugment?
If FE_INEXACT is enabled, yes.
Jakub