Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Feb 1995 20:21:18 +0100
From:      "Christoph P. Kukulies" <kuku@gilberto.physik.rwth-aachen.de>
To:        freebsd-hackers@freefall.cdrom.com
Subject:   Re: fp inline code
Message-ID:  <199502121921.UAA04742@gilberto.physik.rwth-aachen.de>

next in thread | raw e-mail | index | archive | help
> > I want to have gcc produce inline sin, cos, log etc. functions as
> > 387 instructions. Is this possible? I always thought -ffast-math
> > would do that but it still generates call _sin etc.
> 
> You have to use -ffast-math -mfancy-math-387 under FreeBSD to get
> inlined sin, cos and sqrt.  See gcc.info*; this is not documented
> in the manpage.  Other 387 functions are not handled by gcc.
> 
> Bruce

I tried the following:

Script started on Sun Feb 12 20:13:43 1995
blues> cat d.c
main()
{
	int             i;
	double		sin(),sqrt();
        double          a = sin(3.14);
	for (i = 0; i < 1000000; i++)
		a = sin(sqrt(a) + 1.0);
	printf("a=%lf\n", a);
}
blues>
blues> gcc -S -ffast-math -mfancy-math-387 d.
blues> cat d.
	.file	"d.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
LC0:
	.ascii "a=%lf\12\0"
	.align 2
.globl _main
	.type	 _main,@function
_main:
	pushl %ebp
	movl %esp,%ebp
	subl $12,%esp
	call ___main
	pushl $1074339512
	pushl $1374389535
	call _sin
	addl $8,%esp
	fstpl -12(%ebp)
	movl $0,-4(%ebp)
L2:
	cmpl $999999,-4(%ebp)
	jle L5
	jmp L3
	.align 2,0x90
L5:
	pushl -8(%ebp)
	pushl -12(%ebp)
	call _sqrt
	addl $8,%esp
	fld1
	faddp %st,%st(1)
	subl $8,%esp
	fstpl (%esp)
	call _sin
	addl $8,%esp
	fstpl -12(%ebp)
L4:
	incl -4(%ebp)
	jmp L2
	.align 2,0x90
L3:
	pushl -8(%ebp)
	pushl -12(%ebp)
	pushl $LC0
	call _printf
	addl $12,%esp
L1:
	leave
	ret
Lfe1:
	.size	 _main,Lfe1-_main
blues> 

Script done on Sun Feb 12 20:14:28 1995

I don't see sin, sqrt being inlined by fpu instructions. Am I missing
something?

--Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de
FreeBSD blues 2.1.0-Development FreeBSD 2.1.0-Development #0: Tue Feb  7
09:56:53  1995     kuku@blues:/sys/compile/BLUES  i386




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199502121921.UAA04742>