This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: i386 fpu function rewrite


> /* acos = atan (sqrt(1 - x^2) / x) */
> double
> __ieee754_acos (double x)
> {
>   double res;
>   
>   asm ("fld	%%st			/* x : x */
> 	fmul	%%st(0)			/* x^2 : x */
> 	fld1				/* 1 : x^2 : x */
> 	fsubp				/* 1 - x^2 : x */
> 	fsqrt				/* sqrt (1 - x^2) : x */
> 	fxch	%%st(1)			/* x : sqrt (1 - x^2) */
> 	fpatan				/* atan (sqrt(1 - x^2) / x) */"
>        : "=t" (res) : "0" (x) : "st(1)");
Most of the instructions here can be generated by gcc itself.
I would say that it is preferable to use c code that calls few
macros to output instructions like fpatan and similar beasts.

This has advantage, that we can use gcc to optimize functions for given
CPU (beside scheduling there are few optimizations gcc can do, like
replacing fld1 by memory load on Pentium) and in future we would like to
replace macros by intrics, like SSE support have.

On the other hand, the reload pass may bring unnecesary fxch instructions
even in such trivial code streams, so I am not sure this is really good
idea, given that gcc will probably stay weak forever on this side.

Honza
> 
>   return res;
>   
> }
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> This assembles to the same file if I use  -momit-leaf-frame-pointer or
> -fomit-frame-pointer, otherwise the frame pointer is added.
> 
> I can also easily use this file for x86-64.  Is it ok to continue this
> way?  I'd like to send in patches for glibc for e_atan and other
> functions soon.
> 
> Andreas
> -- 
>  Andreas Jaeger
>   SuSE Labs aj@suse.de
>    private aj@arthur.inka.de
>     http://www.suse.de/~aj


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]