This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Constant fold sqrt at compile time (take 2)
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: roger at eyesopen dot com
- Cc: gcc-patches at gcc dot gnu dot org, rth at redhat dot com
- Date: Sun, 3 Nov 2002 09:11:22 -0500 (EST)
- Subject: Re: [PATCH] Constant fold sqrt at compile time (take 2)
- References: <Pine.LNX.4.33.0211022105220.18377-100000@www.eyesopen.com>
> ! /* Optimize sqrt(0.0) = 0.0 and sqrt(1.0) = 1.0. */
> ! if (real_zerop (arg) || real_onep (arg))
> ! return arg;
>
> /* Optimize sqrt(exp(x)) = exp(x/2.0). */
> fcode = builtin_mathfn_code (arg);
> --- 4241,4260 ----
> enum built_in_function fcode;
> tree arg = TREE_VALUE (arglist);
>
> ! /* Optimize sqrt of constant value. */
> ! if (flag_unsafe_math_optimizations
> ! && TREE_CODE (arg) == REAL_CST
> ! && ! TREE_CONSTANT_OVERFLOW (arg))
Minor nit:
Since 0.0 and 1.0 are always safe to optimize, rather than delete
them IMO you should do this:
if (0.0 || 1.0)
return arg;
else if (flag_unsafe_math_optimizations ...
Only kill 0.0 & 1.0 if and when you get this working without
flag_unsafe_math_optimizations.
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu