std::pow implementation
Richard Guenther
rguenth@tat.physik.uni-tuebingen.de
Tue Jul 29 13:22:00 GMT 2003
On Tue, 29 Jul 2003, Paolo Carlini wrote:
> Steven Bosscher wrote:
>
> >I would expect that the RTL inliner can deduce the number of iterations
> >and unroll the loop. All other code is dead at that point and you'd end
> >up with x*x.
> >
> Cool!
Unfortunately not,
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!
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
More information about the Gcc
mailing list