From 2f63a4570c14bd64ab88295180c89482948c61e0 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Sat, 3 Apr 2004 20:05:40 +0000 Subject: [PATCH] fold-const.c (fold): Guard (-A)+B -> B-A transformation with reorder_operands_p. * fold-const.c (fold) : Guard (-A)+B -> B-A transformation with reorder_operands_p. From-SVN: r80381 --- gcc/ChangeLog | 5 +++++ gcc/fold-const.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 16547210234..2575996bca5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-04-03 Roger Sayle + + * fold-const.c (fold) : Guard (-A)+B -> B-A transformation + with reorder_operands_p. + 2004-04-03 Jan Hubicka * md.texi (vec_set, vec_extract, vec_init): Document. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3fc6dd27d0b..e0d2adc09d6 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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)); -- 2.30.2