re PR middle-end/26717 (complex/complex gives a REAL_CST)

PR middle-end/26717
	* fold-const.c (fold_binary) [RDIV_EXPR]: Do not optimize A / A
	to 1.0 for non-real operands. Implement A / A optimization for
	complex operands.


Co-Authored-By: Roger Sayle <roger@eyesopen.com>

From-SVN: r112379
This commit is contained in:
Uros Bizjak 2006-03-25 18:32:34 +01:00 committed by Uros Bizjak
parent 75bcbcdb5e
commit 1d8b38a080
4 changed files with 38 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2006-03-25 Uros Bizjak <uros@kss-loka.si>
Roger Sayle <roger@eyesopen.com>
PR middle-end/26717
* fold-const.c (fold_binary) [RDIV_EXPR]: Do not optimize A / A
to 1.0 for non-real operands. Implement A / A optimization for
complex operands.
2006-03-25 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/i386.c (size_cost): Correct the comment for

View File

@ -8902,8 +8902,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
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)))
NaNs or Infinities. Skip the transformation
for non-real operands. */
if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (arg0))
&& ! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))
&& ! HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg0)))
&& operand_equal_p (arg0, arg1, 0))
{
@ -8912,6 +8914,20 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
return omit_two_operands (type, r, arg0, arg1);
}
/* The complex version of the above A / A optimization. */
if (COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0))
&& operand_equal_p (arg0, arg1, 0))
{
tree elem_type = TREE_TYPE (TREE_TYPE (arg0));
if (! HONOR_NANS (TYPE_MODE (elem_type))
&& ! HONOR_INFINITIES (TYPE_MODE (elem_type)))
{
tree r = build_real (elem_type, dconst1);
/* omit_two_operands will call fold_convert for us. */
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,

View File

@ -1,3 +1,8 @@
2006-03-25 Uros Bizjak <uros@kss-loka.si>
PR middle-end/26717
* gcc.dg/pr26717.c: New test.
2006-03-25 Roger Sayle <roger@eyesopen.com>
* gfortran.dg/dependency_12.f90: New test case.

View File

@ -0,0 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-O -ffast-math" } */
_Complex float f (_Complex float a)
{
_Complex float b = a / a;
return b;
}