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: ::pow(T, n) vs std::pow(T, n) for non-constant n


... however, for the very same loop that I used at the beginning:

 for (int i = 0; i < 100000000; ++i)
   {
     double a = M_PI * i;
     int n = i % 10;
     std::pow(a, n);
     //::pow(a, n);
   }

With -O2 -ffast-math <- IMPORTANT

::pow
-----
0.090u 0.000s 0:00.09 100.0%    0+0k 0+0io 149pf+0w

std::pow
--------
1.540u 0.000s 0:01.54 100.0%    0+0k 0+0io 149pf+0w

Therefore, in the situation displayed above, gcc + builtin pow,
when requested to do so (-ffast-math) is able to establish the
constness of the argument and use the fast optimized code!!!

For sure, in other, more complex, situations this will not happen,
but when, exactly?

The more I try out the behavior of gcc + builtin pow, the more I
become convinced that, for -ffast-math, is so faster than the current
v3 binary algorithm, otherwise, more accurate.

Paolo.


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