This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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] PR11706, optimize std::pow(T, int)


On Wed, 12 Jan 2005, Richard Guenther wrote:

> On Wed, 12 Jan 2005, Richard Guenther wrote:
>
> > On Wed, 12 Jan 2005, Paolo Carlini wrote:
> >
> > > Richard Guenther wrote:
> > >
> > > Maybe Gaby wants to add something here, but I seem to remember that
> > > we really dislike this kind of approach, calling back pow from __pow_helper
> > > via a cast, thus giving away the info that the exponent is integer.
> >
> > We can dispatch directly to __builtin_pow[lf](), too, and the frontends
>
> Like with
>
>       inline _Tp
>       __pow_helper(_Tp __x, int __n)
>       {
> #if __FAST_MATH__
>        if (__builtin_constant_p(__n))
> #else
>        if (__builtin_constant_p(__n) && __n >= -2 && __n <= -2)
> #endif
>          {
>            if (__builtin_types_compatible_p(_Tp, float))
>              return __builtin_powf(__x, __n);
>            else if (__builtin_types_compatible_p(_Tp, double))
>              return __builtin_pow(__x, __n);
>            else if (__builtin_types_compatible_p(_Tp, long double))
>              return __builtin_powl(__x, __n);
>          }

Doesn't work - __builtin_types_compatible_p seems to be available
in C only.  Then of course changing the three pow overloads with
integer exponent works - anyway, the first patch was just the
shortest one.

Richard.

--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/


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