This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix PR17687 sincos -> cexp canonicalization (2nd try)
On Tue, 12 Dec 2006, Richard Guenther wrote:
> On Fri, 8 Dec 2006, Richard Guenther wrote:
> > This moves canonicalization from gimplify to fold as requested and
> > adds folding of cexp as well (as requested). To produce a testcase
> > for the latter I had to add some folding of complex expressions to
> > allow making cexp with an imaginary argument visible to fold. Also
> > gcc.c-torture/execute/complex-1.c needs adjustment because it defines
> > its own cexp with different semantics.
> Here's just the canonicalization part again (I don't like big patches).
> There's the point that from fold_builtin_sincos we generate a MODIFY_EXPR
> which will ICE if we ever do so after gimplification. So I still believe
> this transformation belongs to the gimplifier - even a pass doing proper
> gimplification on a folded tree will hit the ICE as we have in build2
> if (code == MODIFY_EXPR && cfun && cfun->gimplified)
> /* We should be talking GIMPLE_MODIFY_STMT by now. */
> gcc_unreachable ();
> which is IMHO broken. This is more for verify_stmts.
> I believe this patch is certainly non-algorithmic, but for the above
> reason I'd like to have an opinion whether the fold or the gimplify
> variant is what we want.
Applied to mainline. The above problem is harmless as no pass currently
generates calls to sincos.
> 2006-12-06 Richard Guenther <firstname.lastname@example.org>
> PR tree-optimization/17687
> * builtins.def (BUILT_IN_CEXPI, BUILT_IN_CEXPIF, BUILT_IN_CEXPIL):
> New builtins for imaginary argument cexp.
> * builtin-types.def (BT_FN_COMPLEX_FLOAT_FLOAT,
> BT_FN_COMPLEX_DOUBLE_DOUBLE, BT_FN_COMPLEX_LONGDOUBLE_LONGDOUBLE):
> New required builtin types.
> * builtins.c (expand_builtin_cexpi): Declare.
> (mathfn_built_in): Handle BUILT_IN_CEXPI.
> (expand_builtin_cexpi): New static helper.
> (expand_builtin): Call it.
> (do_mpfr_sincos): Adjust for CEXPI evaluation.
> (fold_builtin_sincos): New function to fold sincos to cepxi.
> * testsuite/gcc.dg/builtins-59.c: New testcase.