question on cmath (gcc 4.5.1)
Neal Becker
ndbecker2@gmail.com
Fri Nov 19 04:03:00 GMT 2010
cmath has patterns like this (taking cos as an example):
using ::cos;
inline float
cos(float __x)
{ return __builtin_cosf(__x); }
inline long double
cos(long double __x)
{ return __builtin_cosl(__x); }
template<typename _Tp>
inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
double>::__type
cos(_Tp __x)
{ return __builtin_cos(__x); }
Do I understand correctly, that this means float, long double will use
__builtin_cos(xxx), but plain double will not use __builtin_cos???
I've tried tracing the generated code, and that's the way it looks. It
appears to just call the cos function in glibc.
Is this correct and if so, would not __builtin_cos be faster?
More information about the Gcc-help
mailing list