This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug libstdc++/11706] std::pow(T, int) implementation pessimizes code


------- Additional Comments From rguenth at tat dot physik dot uni-tuebingen dot de  2004-03-11 19:04 -------
Subject: Re:  std::pow(T, int) implementation pessimizes
 code

cvs-commit at gcc dot gnu dot org wrote:
> Log message:
> 	2004-03-11  Steven Bosscher  <s.bosscher@student.tudelft.nl>
> 	
> 	PR libstdc++/11706
> 	* include/c_std/cmath.tcc (__cmath_power): Define inline.

Folks, this is not the right fix.  It doesn't help at all and moves the 
problem to a place where it is harder to fix than before.  Namely now we 
need
- a loop unroller capable of non-linear iv handling
- a inliner that will inline pow(x, c) for c == -1, 0, 1, 2 all the 
time, for constant c if not -Os and otherwise not (probably based on 
profile-feedback).

This ain't gonna happen, even in 3.5 timeframe.  The simplest fix for 
3.4 is replacing the __cmath_power() call with ::pow(), if c is 
constant.  I.e.

   template<typename _Tp>
     inline _Tp
     __pow_helper(_Tp __x, int __n)
     {
       if (__builtin_constant_p(__n))
         return ::pow(__x, __n);
       else
         return __n < 0
           ? _Tp(1)/__cmath_power(__x, -__n)
           : __cmath_power(__x, __n);
     }

This is sitting in my 3.3, 3.4 and ssa trees for month now.

Please remove the SUSPENDED state of the bug.

Richard.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11706


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