Neal Becker <ndbecker2@xxxxxxxxx> writes: > 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? Unless you are using an unusual option like -ffreestanding, the compiler should automatically recognize cos and treat it like __builtin_cos. Ian