]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fold-const.c (associate_trees): Only optimize NEGATE_EXPR in one of the operands...
authorJakub Jelinek <jakub@redhat.com>
Wed, 4 Dec 2002 19:28:27 +0000 (20:28 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 4 Dec 2002 19:28:27 +0000 (20:28 +0100)
* fold-const.c (associate_trees): Only optimize NEGATE_EXPR in one
of the operands into MINUS_EXPR if code is PLUS_EXPR.

* gcc.c-torture/execute/20020805-1.c: New test.

From-SVN: r59824

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog

index 5cc30eb55d5e79437b3f726d2cc1b3c6d143b07b..7a27c2fd34d903e8b23637cdebf315dd0ecc143f 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-04  Jakub Jelinek  <jakub@redhat.com>
+
+       * fold-const.c (associate_trees): Only optimize NEGATE_EXPR in one
+       of the operands into MINUS_EXPR if code is PLUS_EXPR.
+
 2002-12-02  Bob Wilson  <bob.wilson@acm.org>
 
        * config/xtensa/xtensa.c (xtensa_emit_call): Use a static buffer.
index 021faf58e7f6dd9d838bd2dd63e2a2e3c627b3ab..ef247174d91226ad09a70f9bdb5e4fbc1d1e9a62 100644 (file)
@@ -1500,14 +1500,16 @@ associate_trees (t1, t2, code, type)
   if (TREE_CODE (t1) == code || TREE_CODE (t2) == code
       || TREE_CODE (t1) == MINUS_EXPR || TREE_CODE (t2) == MINUS_EXPR)
     {
-      if (TREE_CODE (t1) == NEGATE_EXPR)
-       return build (MINUS_EXPR, type, convert (type, t2),
-                     convert (type, TREE_OPERAND (t1, 0)));
-      else if (TREE_CODE (t2) == NEGATE_EXPR)
-       return build (MINUS_EXPR, type, convert (type, t1),
-                     convert (type, TREE_OPERAND (t2, 0)));
-      else
-       return build (code, type, convert (type, t1), convert (type, t2));
+      if (code == PLUS_EXPR)
+       {
+         if (TREE_CODE (t1) == NEGATE_EXPR)
+           return build (MINUS_EXPR, type, convert (type, t2),
+                         convert (type, TREE_OPERAND (t1, 0)));
+         else if (TREE_CODE (t2) == NEGATE_EXPR)
+           return build (MINUS_EXPR, type, convert (type, t1),
+                         convert (type, TREE_OPERAND (t2, 0)));
+       }
+      return build (code, type, convert (type, t1), convert (type, t2));
     }
 
   return fold (build (code, type, convert (type, t1), convert (type, t2)));
index bd154a8c7ac5f9f38defba2fbc596bf93200577f..5616ee408dc4d697f56cdf16c1ce09d5f3b6028d 100644 (file)
@@ -1,3 +1,7 @@
+2002-12-04  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.c-torture/execute/20020805-1.c: New test.
+
 2002-12-02  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/8615