fold-const.c (fold): Don't transform (a0 op compound(a1,a2)) to (compound(a1,a0 op...
authorAndrew Haley <aph@redhat.com>
Tue, 5 Nov 2002 14:32:24 +0000 (14:32 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Tue, 5 Nov 2002 14:32:24 +0000 (14:32 +0000)
2002-11-05  Andrew Haley  <aph@redhat.com>

        * fold-const.c (fold): Don't transform (a0 op compound(a1,a2))
        to (compound(a1,a0 op a2)) if a0 or a1 have side effects.

From-SVN: r58822

gcc/ChangeLog
gcc/fold-const.c

index ff854be43329cd76a5d8b9a2a35c4c38ab8503ff..31010abd3db0f7bebfe06e8fe5b844354d0b8b89 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-05  Andrew Haley  <aph@redhat.com>
+
+       * fold-const.c (fold): Don't transform (a0 op compound(a1,a2))
+       to (compound(a1,a0 op a2)) if a0 or a1 have side effects.
+
 2002-11-05  Richard Sandiford  <rsandifo@redhat.com>
 
        * config/mips/mips.h (CANNOT_CHANGE_MODE_CLASS): Move comment to...
index c08d44e1e3ec7cc14e6e7c8df74d06f44e420a76..c4095e4dd32ac45e0528095a7fe2dfd482999de8 100644 (file)
@@ -4783,7 +4783,9 @@ fold (expr)
   else if (TREE_CODE_CLASS (code) == '2'
           || TREE_CODE_CLASS (code) == '<')
     {
-      if (TREE_CODE (arg1) == COMPOUND_EXPR)
+      if (TREE_CODE (arg1) == COMPOUND_EXPR
+         && ! TREE_SIDE_EFFECTS (TREE_OPERAND (arg1, 0))
+         && ! TREE_SIDE_EFFECTS (arg0))
        return build (COMPOUND_EXPR, type, TREE_OPERAND (arg1, 0),
                      fold (build (code, type,
                                   arg0, TREE_OPERAND (arg1, 1))));