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 fold sqrt at compile time (take 2)


 > !	      /* 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


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