aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2004-04-03 20:05:40 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2004-04-03 20:05:40 +0000
commit2f63a4570c14bd64ab88295180c89482948c61e0 (patch)
tree8e6a6e539c2c2e8944dd964fda8c850daf1c3d95
parentef1140a912b50510fdf4fd7fdb3b9d243087690b (diff)
downloadgcc-2f63a4570c14bd64ab88295180c89482948c61e0.zip
gcc-2f63a4570c14bd64ab88295180c89482948c61e0.tar.gz
gcc-2f63a4570c14bd64ab88295180c89482948c61e0.tar.bz2
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
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 16547210..2575996 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 3fc6dd2..e0d2adc 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));