aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ff854be..31010ab 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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...
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index c08d44e..c4095e4 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))));