This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] PATCH to SAVE_EXPR gimplification


Previously, gimplification of SAVE_EXPRs would emit any post-effects of the
controlled expression between the initialization and use of the temporary.
With copy propagation, this can result in multiple SSA instances of a
variable being unnecessarily alive at the same time.  This patch changes
things so that post-effects end up on the normal postqueue, avoiding the
problem.

Eventually I would expect us to do some reordering to resolve such
conflicts when possible, but we might as well avoid the problem in the
first place when reasonable.

Booted and tested i686-pc-linux-gnu, applied to tree-ssa branch.

2003-05-20  Jason Merrill  <jason@redhat.com>

	* gimplify.c (simplify_save_expr): Add post-effects to the
	postqueue.

*** gimplify.c.~1~	Tue May 13 15:44:24 2003
--- gimplify.c	Tue May 20 15:45:58 2003
*************** static void simplify_call_expr       PAR
*** 51,57 ****
  static void simplify_tree_list       PARAMS ((tree *, tree *, tree *));
  static void simplify_modify_expr     PARAMS ((tree *, tree *, tree *, int));
  static void simplify_compound_expr   PARAMS ((tree *, tree *));
! static void simplify_save_expr       PARAMS ((tree *, tree *));
  static void simplify_addr_expr       PARAMS ((tree *, tree *, tree *));
  static void simplify_self_mod_expr   PARAMS ((tree *, tree *, tree *));
  static void simplify_cond_expr       PARAMS ((tree *, tree *, tree));
--- 51,57 ----
  static void simplify_tree_list       PARAMS ((tree *, tree *, tree *));
  static void simplify_modify_expr     PARAMS ((tree *, tree *, tree *, int));
  static void simplify_compound_expr   PARAMS ((tree *, tree *));
! static void simplify_save_expr       PARAMS ((tree *, tree *, tree *));
  static void simplify_addr_expr       PARAMS ((tree *, tree *, tree *));
  static void simplify_self_mod_expr   PARAMS ((tree *, tree *, tree *));
  static void simplify_cond_expr       PARAMS ((tree *, tree *, tree));
*************** simplify_expr (expr_p, pre_p, post_p, si
*** 569,575 ****
  	  /* SAVE_EXPR nodes are converted into a SIMPLE identifier and
  	     eliminated.  */
  	case SAVE_EXPR:
! 	  simplify_save_expr (expr_p, pre_p);
  	  break;
  
  	case BIT_FIELD_REF:
--- 570,576 ----
  	  /* SAVE_EXPR nodes are converted into a SIMPLE identifier and
  	     eliminated.  */
  	case SAVE_EXPR:
! 	  simplify_save_expr (expr_p, pre_p, post_p);
  	  break;
  
  	case BIT_FIELD_REF:
*************** simplify_compound_expr (expr_p, pre_p)
*** 1852,1875 ****
          *EXPR_P should be stored.  */
  
  static void
! simplify_save_expr (expr_p, pre_p)
       tree *expr_p;
       tree *pre_p;
  {
  #if defined ENABLE_CHECKING
    if (TREE_CODE (*expr_p) != SAVE_EXPR)
      abort ();
  #endif
  
    /* If the operand is already a SIMPLE temporary, just re-write the
       SAVE_EXPR node.  */
!   if (is_simple_tmp_var (TREE_OPERAND (*expr_p, 0)))
!     *expr_p = TREE_OPERAND (*expr_p, 0);
    else
      {
!       TREE_OPERAND (*expr_p, 0) =
! 	get_initialized_tmp_var (TREE_OPERAND (*expr_p, 0), pre_p);
!       *expr_p = TREE_OPERAND (*expr_p, 0);
      }
  }
  
--- 1931,1961 ----
          *EXPR_P should be stored.  */
  
  static void
! simplify_save_expr (expr_p, pre_p, post_p)
       tree *expr_p;
       tree *pre_p;
+      tree *post_p;
  {
+   tree val;
+ 
  #if defined ENABLE_CHECKING
    if (TREE_CODE (*expr_p) != SAVE_EXPR)
      abort ();
  #endif
  
+   val = TREE_OPERAND (*expr_p, 0);
+ 
    /* If the operand is already a SIMPLE temporary, just re-write the
       SAVE_EXPR node.  */
!   if (is_simple_tmp_var (val))
!     *expr_p = val;
    else
      {
!       /* Simplify this now so post-effects go on the normal postqueue.  */
!       simplify_expr (&val, pre_p, post_p, is_simple_rhs, fb_rvalue);
!       val = get_initialized_tmp_var (val, pre_p);
!       TREE_OPERAND (*expr_p, 0) = val;
!       *expr_p = val;
      }
  }
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]