Re: question on cmath (gcc 4.5.1)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux