This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Perform constant folding of math builtins
- From: Richard Henderson <rth at redhat dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 Aug 2002 02:12:43 -0700
- Subject: Re: [PATCH] Perform constant folding of math builtins
- References: <Pine.LNX.4.33.0208251925340.26698-100000@www.eyesopen.com>
On Sun, Aug 25, 2002 at 08:17:55PM -0600, Roger Sayle wrote:
> * builtins.c (build_function_call_expr): Remove prototype, export
> as non-static and add a comment above function definition.
> (builtin_mathfn_p): New function to check for math builtins.
> (fold_builtin): Optimize sqrt(0.0) as 0.0, sqrt(1.0) as 1.0,
> exp(0.0) as 1.0, and log(1.0) as 0.0. Optimize exp(log(x)) and
> log(exp(x)) as x. Optimize sqrt(exp(x)) as exp(x/2.0) and
> log(sqrt(x)) as log(x)/2.0.
>
> * tree.h: Prototype build_function_call_expr and builtin_mathfn_p
> in new "builtins.c" section. Place the build_range_type prototype
> with the other prototypes from "tree.c".
>
> * fold-const.c (fold) [ABS_EXPR]: Fold fabs(sqrt(x)) as sqrt(x)
> and fabs(exp(x)) as exp(x). [MULT_EXPR]: Fold sqrt(x)*sqrt(y)
> as sqrt(x*y) and exp(x)*exp(y) as exp(x+y). [RDIV_EXPR]: Fold
> x/exp(y) as x*exp(-y).
>
> * gcc.dg/builtins-2.c: New test case.
> * gcc.dg/builtins-3.c: New test case.
Ok for basic-improvements-branch, and thus 3.4.
r~