[PATCH] PR11706, optimize std::pow(T, int)

Gabriel Dos Reis gdr@integrable-solutions.net
Wed Jan 12 15:55:00 GMT 2005


Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:

[...]

| > And, after Zdenek nice patch, -funroll-loops should lead to optimal code.
| > Does it work as expected?
| 
| Yes, __cmath_power is inlined and -funroll-loops is able to optimize
| the loop for constant powers.  Though the approach in __cmath_power
| is not optimal, f.i. for a exponent of 27 we generate one more
| multiplication than with __builtin_pow().  Also, as we inline
| __cmath_power all the time now, we have icache and code-size regressions
| for not constant powers.  With my hackish approach we could again
| remove these inlines.  Also, having to enable -funroll-loops to

So, what you want is to have the compiler better understand loop with
"constant" bounds, without requiring -funroll-loops.

-- Gaby



More information about the Libstdc++ mailing list