This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: std::pow implementation
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>, Gabriel Dos Reis <gdr at integrable-solutions dot net>, <gcc at gcc dot gnu dot org>
- Date: Tue, 29 Jul 2003 14:55:00 +0200 (CEST)
- Subject: Re: std::pow implementation
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/