fold-const.c (fold): Guard (-A)+B -> B-A transformation with reorder_operands_p.

* fold-const.c (fold) <PLUS_EXPR>: Guard (-A)+B -> B-A transformation
	with reorder_operands_p.

From-SVN: r80381
This commit is contained in:
Roger Sayle 2004-04-03 20:05:40 +00:00 committed by Roger Sayle
parent ef1140a912
commit 2f63a4570c
2 changed files with 8 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2004-04-03 Roger Sayle <roger@eyesopen.com>
* fold-const.c (fold) <PLUS_EXPR>: Guard (-A)+B -> B-A transformation
with reorder_operands_p.
2004-04-03 Jan Hubicka <jh@suse.cz>
* md.texi (vec_set, vec_extract, vec_init): Document.

View File

@ -5861,9 +5861,10 @@ fold (tree expr)
if (TREE_CODE (arg1) == NEGATE_EXPR)
return fold (build (MINUS_EXPR, type, arg0, TREE_OPERAND (arg1, 0)));
/* (-A) + B -> B - A */
if (TREE_CODE (arg0) == NEGATE_EXPR)
if (TREE_CODE (arg0) == NEGATE_EXPR
&& reorder_operands_p (TREE_OPERAND (arg0, 0), arg1))
return fold (build (MINUS_EXPR, type, arg1, TREE_OPERAND (arg0, 0)));
else if (! FLOAT_TYPE_P (type))
if (! FLOAT_TYPE_P (type))
{
if (integer_zerop (arg1))
return non_lvalue (fold_convert (type, arg0));