This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to build_modify_expr
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 May 2003 13:01:31 -0400
- Subject: C++ PATCH to build_modify_expr
build_modify_expr has been over-enthusiastic about applying
stabilize_reference to the sides of a MODIFY_EXPR, which generates
unnecessary SAVE_EXPRs. We only need to stabilize the lhs when and if we
actually pull it out and use it again in another expression; most places in
the compiler already do this. This patch fixes the one straggler.
Tested i686-pc-linux-gnu, applied to trunk and tree-ssa.
2003-05-13 Jason Merrill <jason@redhat.com>
* typeck.c (build_modify_expr): Don't always stabilize the lhs and
rhs. Do stabilize the lhs of a MODIFY_EXPR used on the lhs.
*** typeck.c.~1~ 2003-05-12 05:09:05.000000000 -0400
--- typeck.c 2003-05-08 15:59:36.000000000 -0400
*************** build_modify_expr (lhs, modifycode, rhs)
*** 5326,5331 ****
--- 5326,5335 ----
TREE_OPERAND (lhs, 0), newrhs);
case MODIFY_EXPR:
+ if (TREE_SIDE_EFFECTS (TREE_OPERAND (lhs, 0)))
+ lhs = build (TREE_CODE (lhs), TREE_TYPE (lhs),
+ stabilize_reference (TREE_OPERAND (lhs, 0)),
+ TREE_OPERAND (lhs, 1));
newrhs = build_modify_expr (TREE_OPERAND (lhs, 0), modifycode, rhs);
if (newrhs == error_mark_node)
return error_mark_node;
*************** build_modify_expr (lhs, modifycode, rhs)
*** 5531,5544 ****
}
}
- if (TREE_CODE (lhstype) != REFERENCE_TYPE)
- {
- if (TREE_SIDE_EFFECTS (lhs))
- lhs = stabilize_reference (lhs);
- if (TREE_SIDE_EFFECTS (newrhs))
- newrhs = stabilize_reference (newrhs);
- }
-
/* Convert new value to destination type. */
if (TREE_CODE (lhstype) == ARRAY_TYPE)
--- 5535,5540 ----