From 7f5e63076a3e596e2dd88825f0fe2659c20a5e84 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sun, 22 Aug 2004 14:58:48 -0700 Subject: [PATCH] tree.h (SAVE_EXPR_RESOLVED_P): New. * tree.h (SAVE_EXPR_RESOLVED_P): New. * gimplify.c (gimplify_save_expr): Use it. * expr.c (expand_expr_real_1): Likewise. Also set DECL_IGNORED_P on the temporary variable. From-SVN: r86387 --- gcc/ChangeLog | 7 +++++++ gcc/expr.c | 4 +++- gcc/gimplify.c | 37 +++++++++++++++++++------------------ gcc/tree.h | 7 +++++++ 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index df344189066..af7e4d471fd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2004-08-22 Richard Hendersion + + * tree.h (SAVE_EXPR_RESOLVED_P): New. + * gimplify.c (gimplify_save_expr): Use it. + * expr.c (expand_expr_real_1): Likewise. Also set DECL_IGNORED_P + on the temporary variable. + 2004-08-22 Andrew Pinski * fold-const.c (rtl_expr_nonnegative_p): Delete. diff --git a/gcc/expr.c b/gcc/expr.c index c0f10d914bb..81b103d0616 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6497,7 +6497,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, tree val = TREE_OPERAND (exp, 0); rtx ret = expand_expr_real_1 (val, target, tmode, modifier, alt_rtl); - if (TREE_CODE (val) != VAR_DECL || !DECL_ARTIFICIAL (val)) + if (!SAVE_EXPR_RESOLVED_P (exp)) { /* We can indeed still hit this case, typically via builtin expanders calling save_expr immediately before expanding @@ -6508,7 +6508,9 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, val = build_decl (VAR_DECL, NULL, TREE_TYPE (exp)); DECL_ARTIFICIAL (val) = 1; + DECL_IGNORED_P (val) = 1; TREE_OPERAND (exp, 0) = val; + SAVE_EXPR_RESOLVED_P (exp) = 1; if (!CONSTANT_P (ret)) ret = copy_to_reg (ret); diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 3dba42d9b85..3c9ff202dc4 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -3068,27 +3068,28 @@ gimplify_save_expr (tree *expr_p, tree *pre_p, tree *post_p) val = TREE_OPERAND (*expr_p, 0); - /* If the operand is already a GIMPLE temporary, just re-write the - SAVE_EXPR node. */ - if (TREE_CODE (val) == VAR_DECL && DECL_GIMPLE_FORMAL_TEMP_P (val)) - *expr_p = val; - /* The operand may be a void-valued expression such as SAVE_EXPRs - generated by the Java frontend for class initialization. It is - being executed only for its side-effects. */ - else if (TREE_TYPE (val) == void_type_node) + /* If the SAVE_EXPR has not been resolved, then evaluate it once. */ + if (!SAVE_EXPR_RESOLVED_P (*expr_p)) { - tree body = TREE_OPERAND (*expr_p, 0); - ret = gimplify_expr (& body, pre_p, post_p, is_gimple_stmt, fb_none); - append_to_statement_list (body, pre_p); - *expr_p = NULL; - } - else - { - val = get_initialized_tmp_var (val, pre_p, post_p); - DECL_GIMPLE_FORMAL_TEMP_P (val) = 1; - *expr_p = TREE_OPERAND (*expr_p, 0) = val; + /* The operand may be a void-valued expression such as SAVE_EXPRs + generated by the Java frontend for class initialization. It is + being executed only for its side-effects. */ + if (TREE_TYPE (val) == void_type_node) + { + ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p, + is_gimple_stmt, fb_none); + append_to_statement_list (TREE_OPERAND (*expr_p, 0), pre_p); + val = NULL; + } + else + val = get_initialized_tmp_var (val, pre_p, post_p); + + TREE_OPERAND (*expr_p, 0) = val; + SAVE_EXPR_RESOLVED_P (*expr_p) = 1; } + *expr_p = val; + return ret; } diff --git a/gcc/tree.h b/gcc/tree.h index 310704174b3..c8f3c5eb1f9 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -232,6 +232,8 @@ struct tree_common GTY(()) ASM_EXPR TYPE_CACHED_VALUES_P in ..._TYPE + SAVE_EXPR_RESOLVED_P in + SAVE_EXPR private_flag: @@ -788,6 +790,11 @@ extern void tree_operand_check_failed (int, enum tree_code, of cached values, or is something else. */ #define TYPE_CACHED_VALUES_P(NODE) (TYPE_CHECK(NODE)->common.public_flag) +/* In a SAVE_EXPR, indicates that the original expression has already + been substituted with a VAR_DECL that contains the value. */ +#define SAVE_EXPR_RESOLVED_P(NODE) \ + (TREE_CHECK (NODE, SAVE_EXPR)->common.public_flag) + /* In any expression, decl, or constant, nonzero means it has side effects or reevaluation of the whole expression could produce a different value. This is set if any subexpression is a function call, a side effect or a