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]

[RFC PATCH]: Fold (A / A) to 1.0 (not always!)


 > +      /* Optimize A / A to 1.0 if only finite math is allowed.
 > +       Return NaN if A equals 0.0.  */
 > +      if (flag_finite_math_only && !flag_trapping_math
 > +        && operand_equal_p (arg0, arg1, 0))
 > +	 {
 > +	   REAL_VALUE_TYPE qnan;
 > +	     tree tem = build2 (LTGT_EXPR, type, arg0,
 > +		           build_real (TREE_TYPE (arg0), dconst0));
 > +
 > +	  real_nan (&qnan, "", 1, TYPE_MODE (type));
 > +
 > +	  return fold_build3 (COND_EXPR, type, tem,
 > +			           build_real (TREE_TYPE (arg0), dconst1),
 > +			      build_real (TREE_TYPE (arg0), qnan));
 > +			      }
 > +

Don't you need to account for side-effects in "A" when converting
"A/A" into "A<>0?1:NaN" ?  Try using omit_one_operand().

Also, does using tree_expr_nonzero_p() help here?  The comments of the
function indicate it works for floats, but the beginning of the actual
code returns if the tree type isn't integral...

		--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]