This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Perform constant folding of math builtins


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]