This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] PR11706, optimize std::pow(T, int)
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ at gcc dot gnu dot org,Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Date: Wed, 12 Jan 2005 16:48:12 +0100 (CET)
- Subject: 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/