This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFC PATCH]: Fold (A / A) to 1.0 (not always!)
- From: "Kaveh R. Ghazi" <ghazi at caipclassic dot rutgers dot edu>
- To: ubizjak at gmail dot com, uros dot bizjak at kss-loka dot si
- Cc: gcc-patches at gcc dot gnu dot org, paolo dot bonzini at lu dot unisi dot ch
- Date: Wed, 26 Oct 2005 10:45:05 -0400 (EDT)
- Subject: [RFC PATCH]: Fold (A / A) to 1.0 (not always!)
- References: <1130322548.435f5a7449de5@ssl.kss-loka.si>
> + /* 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