[PATCH] sincos() built-in handling

Uros Bizjak uros@kss-loka.si
Fri Apr 9 10:14:00 GMT 2004


Hello!

Attached to this message, please find a patch which implement sincos 
built-in handling. Patch is tested and could be commited to CVS. This 
patch assumes, that operators to expand_twoval_optab() function are 
already in the right order, otherwise optabs.diff patch is needed.

2004-04-09  Uros Bizjak  <uros@kss-loka.si>

       * builtins.c (expand_builtin): Expand BUILT_IN_SINCOS{,F,L} using
       expand_builtin_sincos if flag_unsafe_math_optimizations is set.
       (expand_builtin_sincos): New function.

testsuite:

       * gcc.dg/i386-387-5.c: Add new test for __builtin_sincos.
       * gcc.dg/i386-387-6.c: Likewise.


Because this patch links sincos() built-in to already implemented sincos 
handling, gcc will detect if one of sincos()'s function operators are 
not used and it will convert fsincos instruction into fsin or fcos.

Testcase:
void sincos_test(double a, double *s, double *c) {

        sincos(a, s, c);
}

will be compiled into:
sincos_test:
        pushl   %ebp
        movl    %esp, %ebp
        fldl    8(%ebp)
        fsincos
        fxch    %st(1)
        movl    16(%ebp), %eax
        fstpl   (%eax)
        movl    20(%ebp), %eax
        fstpl   (%eax)
        popl    %ebp
        ret


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sincos.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040409/94f5338b/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: optabs.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040409/94f5338b/attachment-0001.ksh>


More information about the Gcc-patches mailing list