From: Andrew Haley Date: Tue, 5 Nov 2002 14:32:24 +0000 (+0000) Subject: fold-const.c (fold): Don't transform (a0 op compound(a1,a2)) to (compound(a1,a0 op... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5c7cd6636da2ffa19df7094f396362b6c8b35153;p=gcc.git fold-const.c (fold): Don't transform (a0 op compound(a1,a2)) to (compound(a1,a0 op a2)) if... 2002-11-05 Andrew Haley * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ff854be4332..31010abd3db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-11-05 Andrew Haley + + * 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 * config/mips/mips.h (CANNOT_CHANGE_MODE_CLASS): Move comment to... diff --git a/gcc/fold-const.c b/gcc/fold-const.c index c08d44e1e3e..c4095e4dd32 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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))));