OSDN Git Service

* tree.h (SAVE_EXPR_RESOLVED_P): New.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 22 Aug 2004 21:58:48 +0000 (21:58 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 22 Aug 2004 21:58:48 +0000 (21:58 +0000)
        * gimplify.c (gimplify_save_expr): Use it.
        * expr.c (expand_expr_real_1): Likewise.  Also set DECL_IGNORED_P
        on the temporary variable.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86387 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/expr.c
gcc/gimplify.c
gcc/tree.h

index df34418..af7e4d4 100644 (file)
@@ -1,3 +1,10 @@
+2004-08-22  Richard Hendersion  <rth@redhat.com>
+
+       * 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  <pinskia@physics.uc.edu>
 
        * fold-const.c (rtl_expr_nonnegative_p): Delete.
index c0f10d9..81b103d 100644 (file)
@@ -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);
index 3dba42d..3c9ff20 100644 (file)
@@ -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;
 }
 
index 3107041..c8f3c5e 100644 (file)
@@ -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