Commit ffbc33cc by Uros Bizjak Committed by Uros Bizjak

fold-const.c (fold_binary): Optimize A / A to 1.0 if we don't care about NaNs or Infinities.

        * fold-const.c (fold_binary) <RDIV_EXPR>: Optimize A / A to 1.0 
        if we don't care about NaNs or Infinities.

testsuite:

        * gcc.dg/fold-div-2.c: New test.

From-SVN: r107282
parent 083a9e91
2005-11-21 Uros Bizjak <uros@kss-loka.si>
* fold-const.c (fold_binary) <RDIV_EXPR>: Optimize A / A to 1.0
if we don't care about NaNs or Infinities.
2005-11-20 Ian Lance Taylor <ian@airs.com>
PR rtl-optimization/24883
......
......@@ -8227,6 +8227,17 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
&& real_zerop (arg1))
return NULL_TREE;
/* Optimize A / A to 1.0 if we don't care about
NaNs or Infinities. */
if (! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))
&& ! HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg0)))
&& operand_equal_p (arg0, arg1, 0))
{
tree r = build_real (TREE_TYPE (arg0), dconst1);
return omit_two_operands (type, r, arg0, arg1);
}
/* (-A) / (-B) -> A / B */
if (TREE_CODE (arg0) == NEGATE_EXPR && negate_expr_p (arg1))
return fold_build2 (RDIV_EXPR, type,
......
2005-11-21 Uros Bizjak <uros@kss-loka.si>
* gcc.dg/fold-div-2.c: New test.
2005-11-20 Ian Lance Taylor <ian@airs.com>
PR rtl-optimization/24883
/* { dg-do compile } */
/* { dg-options "-ffinite-math-only -fdump-tree-gimple" } */
double f(double x)
{
return x / x;
}
/* Division should be turned into 1.0. */
/* { dg-final { scan-tree-dump-not " / " "gimple" } } */
/* { dg-final { cleanup-tree-dump "gimple" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment