[PATCH] Expand sincos using optab, if possible

Roger Sayle roger@eyesopen.com
Fri Jan 13 06:55:00 GMT 2006


On Wed, 11 Jan 2006, Richard Guenther wrote:
> 2006-01-11  Richard Guenther  <rguenther@suse.de>
>
> 	* builtins.c (expand_builtin_sincos): New function.
> 	(expand_builtin_mathfn_3): Remove dead code, sin and cos
> 	do not set errno.
> 	(expand_builtin): Expand sincos using expand_builtin_sincos.
>
> 	* gcc.target/i386/387-9.c: New testcase.

Cool!  This is OK for mainline, with the minor revision below:

> +   start_sequence ();
...
> +   /* Output the entire sequence.  */
> +   insns = get_insns ();
> +   end_sequence ();
> +   emit_insn (insns);

I believe that you can delete these lines.  The other expand_builtin_math*
functions encapsulate their RTL generation in a sequence, so that if
something goes wrong they can clean-up after themselves without having
affected the function's RTL.  In your expand_builtin_sincos function,
you gcc_assert that expand_twoval_unop always succeeds, so the "..."
above is a single-entry-single-exit region.

I even tried -O2 -ffast-math -mno-fancymath-387 to see whether I could
inadvertantly trigger an assertion failure, but without luck.  All uses
of expand_twoval_unop seem to have a similar assertion, so this all
looks reasonable.  If someone ever manages to get result == NULL_RTX,
you can add back the sequence lines above and clean-up nicely rather
than abort.

Thanks again,

Roger
--



More information about the Gcc-patches mailing list