This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: std::pow implementation
- From: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- To: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- Cc: Paolo Carlini <pcarlini at unitus dot it>, Gabriel Dos Reis <gdr at integrable-solutions dot net>, gcc at gcc dot gnu dot org
- Date: 29 Jul 2003 15:01:53 +0200
- Subject: Re: std::pow implementation
- References: <Pine.LNX.4.44.0307291453350.14031-100000@bellatrix.tat.physik.uni-tuebingen.de>
Op di 29-07-2003, om 14:55 schreef Richard Guenther:
> double foo2(double x)
> {
> pow(x, 2);
> }
>
> gets to (with gcc3.4, __cmath_power declared inline, -O2 -funroll-loops
> -ffast-math)
>
> _Z4foo2d:
> .LFB12:
> pushl %ebp #
> .LCFI4:
> movl %esp, %ebp #,
> .LCFI5:
> fldl 8(%ebp) # x
> fld1
> movl $1, %eax #, __n
> jmp .L62 #
> .p2align 4,,7
> .L73:
> fxch %st(1) #
> .L62:
> fxch %st(1) #
> testb $1, %al #, __n
> fmul %st(0), %st #,
> je .L59 #,
> fmul %st, %st(1) #,
> .L59:
> shrl %eax # __n
> jne .L73 #,
> fstp %st(0) #
> popl %ebp #
> ret
>
> yay!
Not that it didn't even unroll the loop at all.
I have no idea if it makes any difference, I'm just curious: What
happens if you replace
while (__n >>= 1)
with
while (__n = __n / 2)
?
Maybe the loop stuff can't handle shifts...
Gr.
Steven