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] Constant folding pow(x,y) for constant y.


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


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