[PATCH] generate fsincos x87 insn

Uros Bizjak uros@kss-loka.si
Mon Apr 5 11:01:00 GMT 2004


Hello!

Attached to this message, please find a patch to implement x87's fsincos 
instruction. Patch is tested, and produces fsincos instruction when 
appropriate. Fsincos instruction generation is totally transparent: if a 
sin() instruction can be combined with matched cos(), then fsincos is 
generated.

Please, could someone review this patch and eventually commit it to CVS. 
Diff is against current mainline.

BTW: I think, that m68k's fsincos instruction can be easily implemented 
the way it is implemented in attached i386.md diff.

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

        * builtins.c: Implement support for sincos function.
        (expand_builtin_mathfn) Remove BUILT_IN_SIN{,F,L} and
        BUILT_IN_COS{,F,L}.
        (expand_builtin_mathfn_3): New function.
        (expand_builtin): Expand BUILT_IN_SIN{,F,L} and
        BUILT_IN_COS{,F,L} using expand_builtin_mathfn_3 if
        flag_unsafe_math_optimization is set.

        * optabs.h (enum optab_index): Add new OTI_sincos.
        (sincos_optab): Define corresponding macro.

        * optabs.c (init_optabs): Initialize sincos_optab.
        (expand_twoval_unop): New function.

        * genopinit.c (optabs): Implement sincos_optab using sincos?f3
        patterns.

        * reg-stack.c (subst_stack_regs_pat): Handle UNSPEC_SINCOS_COS
        and UNSPEC_SINCOS_SIN.

        * config/i386/i386.md (sincosdf3, sincossf3, *sincosextendsfdf3,
        sincosxf3): New patterns to implement sincos, sincosf and sincosl
        built-ins as inline x87 intrinsics. Define splits for
        sindf2, sinsf2, *sinextendsfdf2, sinxf2, cosdf2,
        cossf2, *cosextendsfdf2 and cosxf2 patterns from corresponding
        sincos patterns.
        (sindf2, sinsf2, sinxf2): Rename to *sindf2, *sinsf2, *sinxf2.
        (cosdf2, cossf2, cosxf2): Rename to *cosdf2, *cossf2, *cosxf2.

        (UNSPEC_SINCOS_SIN, UNPEC_SINCOS_COS): New unspecs to represent
        x87's unspec insn.

        * gcc.dg/builtins-36.c: New test.


BTW2: Also attached is an ASM result of builtins-36.c testcase, compiled 
with -O2 -ffast-math.

Thanks,
Uros.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sincos.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040405/c710be31/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: builtins-36.c
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040405/c710be31/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: builtins-36.s
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040405/c710be31/attachment-0001.ksh>


More information about the Gcc-patches mailing list