This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Constant folding pow(x,y) for constant y.
- From: Jonathan Lennox <lennox at cs dot columbia dot edu>
- To: Roger Sayle <roger at www dot eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 31 Mar 2003 11:21:01 -0500
- Subject: Re: [PATCH] Constant folding pow(x,y) for constant y.
- References: <Pine.LNX.4.44.0303301629540.5745-100000@www.eyesopen.com>
Roger Sayle writes:
> The following patch is another installment in my series of constant
> folding optimizations for the pow(3) builtin-function. This round
> performs constant folding of pow(x,y) where y is a constant.
>
> * builtins.c (fold_builtin): When optimizing sqrt(exp(x)) as
> exp(x/2.0) remember to fold the division if possible.
> Fold sin(0.0) as 0.0, cos(0.0) as 1.0, pow(x,1.0) as x,
> pow(x,-1.0) as 1.0/x, pow(x,2.0) as x*x, pow(x,-2.0) as
> 1.0/(x*x) and pow(x,0.5) as sqrt(x).
I don't know how significant it is, but for symmetry's sake, would it be
sensible to include pow(x, -0.5) in your list of constants to optimize, as
1.0/sqrt(x)?
Or is the reciprocal plus the sqrt() unlikely to be a win vs. the call to
pow()?
--
Jonathan Lennox
lennox at cs dot columbia dot edu