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]

gcse.c and flow patch



If gcse tries to replace and expression with more than a single insn,
we dont get the block information set properly, so add a new routine to 
do it correctly. Furthermore, set_block_num () is a deprecated function
in flow.c that only gcse.c is using, so abandon it as well.

A couple of these changes build on top of the previous load/store 
motion patch. If applied without that patch, a few lines would be
rejected, but thats ok.

Bootstrapped and verified on x86 linux.

Andrew


2001-04-03  Andrew MacLeod  <amacleod@redhat.com>

	* basic-block.h (set_new_block_for_insns): New Prototype.
	(set_block_num): Delete prototype.
	* flow.c (set_block_num): Remove obsolete function.
	(set_block_for_new_insns): Set BB for single or multiple insns.
	* gcse.c (handle_avail_expr): Use set_block_for_new_insns.
	(process_insn_end_bb): Use set_block_for_new_insns or 
	set_block_for_insn instead of set_block_num.
	(pre_insert_copy_insn): Use set_block_for_new_insns.
	(update_ld_motion_stores): Use set_block_for_new_insns.
	(insert_insn_start_bb): Use set_block_for_new_insns.
	(replace_store_insn): Use set_block_for_new_insns.


*** gcse.c	Tue Mar 20 13:53:09 2001
--- ../gcse.c	Tue Mar 20 13:53:44 2001
*************** handle_avail_expr (insn, expr)
*** 3548,3554 ****
  			   insn_computes_expr);
  
        /* Keep block number table up to date.  */
!       set_block_num (new_insn, BLOCK_NUM (insn_computes_expr));
  
        /* Keep register set table up to date.  */
        record_one_set (REGNO (to), new_insn);
--- 3548,3554 ----
  			   insn_computes_expr);
  
        /* Keep block number table up to date.  */
!       set_block_for_new_insns (new_insn, BLOCK_FOR_INSN (insn_computes_expr));
  
        /* Keep register set table up to date.  */
        record_one_set (REGNO (to), new_insn);
*************** insert_insn_end_bb (expr, bb, pre)
*** 4807,4813 ****
  	{
  	  rtx insn = XVECEXP (pat, 0, i);
  
! 	  set_block_num (insn, bb);
  	  if (INSN_P (insn))
  	    add_label_notes (PATTERN (insn), new_insn);
  
--- 4807,4813 ----
  	{
  	  rtx insn = XVECEXP (pat, 0, i);
  
! 	  set_block_for_insn (insn, BASIC_BLOCK (bb));
  	  if (INSN_P (insn))
  	    add_label_notes (PATTERN (insn), new_insn);
  
*************** insert_insn_end_bb (expr, bb, pre)
*** 4817,4823 ****
    else
      {
        add_label_notes (SET_SRC (pat), new_insn);
!       set_block_num (new_insn, bb);
  
        /* Keep register set table up to date.  */
        record_one_set (regno, new_insn);
--- 4817,4823 ----
    else
      {
        add_label_notes (SET_SRC (pat), new_insn);
!       set_block_for_new_insns (new_insn, BASIC_BLOCK (bb));
  
        /* Keep register set table up to date.  */
        record_one_set (regno, new_insn);
*************** pre_insert_copy_insn (expr, insn)
*** 4941,4947 ****
  			      insn);
  
    /* Keep block number table up to date.  */
!   set_block_num (new_insn, bb);
  
    /* Keep register set table up to date.  */
    record_one_set (regno, new_insn);
--- 4941,4947 ----
  			      insn);
  
    /* Keep block number table up to date.  */
!   set_block_for_new_insns (new_insn, BASIC_BLOCK (bb));
  
    /* Keep register set table up to date.  */
    record_one_set (regno, new_insn);
*************** update_ld_motion_stores (expr)
*** 6351,6357 ****
  	  copy = gen_move_insn ( reg, SET_SRC (pat));
  	  i = emit_insn_before (copy, insn);
  	  record_one_set (REGNO (reg), i);
! 	  set_block_num (i, BLOCK_NUM (insn));
  	  SET_SRC (pat) = reg;
  
  	  /* un-recognize this pattern since it's probably different now.  */
--- 6351,6357 ----
  	  copy = gen_move_insn ( reg, SET_SRC (pat));
  	  i = emit_insn_before (copy, insn);
  	  record_one_set (REGNO (reg), i);
! 	  set_block_for_new_insns (i, BLOCK_FOR_INSN (insn));
  	  SET_SRC (pat) = reg;
  
  	  /* un-recognize this pattern since it's probably different now.  */
*************** insert_insn_start_bb (insn, bb)
*** 6861,6871 ****
  
    if (prev == BLOCK_END (bb))
      BLOCK_END (bb) = insn;
!   while (insn != prev)
!     {
!       set_block_num (insn, bb);
!       insn = PREV_INSN (insn);
!     }
  
    if (gcse_file)
      {
--- 6861,6868 ----
  
    if (prev == BLOCK_END (bb))
      BLOCK_END (bb) = insn;
! 
!   set_block_for_new_insns (insn, BASIC_BLOCK (bb));
  
    if (gcse_file)
      {
*************** replace_store_insn (reg, del, bb)
*** 6955,6961 ****
    
    insn = gen_move_insn (reg, SET_SRC (PATTERN (del)));
    insn = emit_insn_after (insn, del);
!   set_block_num (insn, bb);
    
    if (gcse_file)
      {
--- 6952,6958 ----
    
    insn = gen_move_insn (reg, SET_SRC (PATTERN (del)));
    insn = emit_insn_after (insn, del);
!   set_block_for_new_insns (insn, BASIC_BLOCK (bb));
    
    if (gcse_file)
      {
*** basic-block.h	Tue Mar 20 13:53:07 2001
--- ../basic-block.h	Tue Mar 20 13:53:44 2001
*************** extern varray_type basic_block_for_insn;
*** 238,244 ****
  extern void compute_bb_for_insn		PARAMS ((int));
  extern void update_bb_for_insn		PARAMS ((basic_block));
  extern void set_block_for_insn		PARAMS ((rtx, basic_block));
! extern void set_block_num		PARAMS ((rtx, int));
  
  extern void free_basic_block_vars	PARAMS ((int));
  
--- 238,244 ----
  extern void compute_bb_for_insn		PARAMS ((int));
  extern void update_bb_for_insn		PARAMS ((basic_block));
  extern void set_block_for_insn		PARAMS ((rtx, basic_block));
! extern void set_block_for_new_insns	PARAMS ((rtx, basic_block));
  
  extern void free_basic_block_vars	PARAMS ((int));
  
*** flow.c	Tue Mar 20 13:53:09 2001
--- ../flow.c	Tue Mar 20 13:53:44 2001
*************** set_block_for_insn (insn, bb)
*** 6876,6890 ****
    VARRAY_BB (basic_block_for_insn, uid) = bb;
  }
  
! /* Record INSN's block number as BB.  */
! /* ??? This has got to go.  */
  
  void
! set_block_num (insn, bb)
       rtx insn;
!      int bb;
  {
!   set_block_for_insn (insn, BASIC_BLOCK (bb));
  }
  
  /* Verify the CFG consistency.  This function check some CFG invariants and
--- 6876,6913 ----
    VARRAY_BB (basic_block_for_insn, uid) = bb;
  }
  
! /* When a new insn has been inserted into an existing block, it will
!    sometimes emit more than a single insn. This routine will set the
!    block number for the specified insn, and look backwards in the insn
!    chain to see if there are any other uninitialized insns immediately 
!    previous to this one, and set the block number for them too.  */
  
  void
! set_block_for_new_insns (insn, bb)
       rtx insn;
!      basic_block bb;
  {
!   set_block_for_insn (insn, bb);
! 
!   /* We dont scan to set the block to 0 since this is the default value.  
!      If we did, we'd end up scanning/setting the entire prologue block
!      everytime we insert an insn into it. */
!   if (bb->index == 0)
!     return;
! 
!   /* Scan the previous instructions setting the block number until we find 
!      an instruction that has the block number set, or we find a note 
!      of any kind.  */
!   for (insn = PREV_INSN (insn); insn != NULL_RTX; insn = PREV_INSN (insn))
!     {
!       if (GET_CODE (insn) == NOTE)
! 	break;
!       if ((size_t)INSN_UID (insn) >= basic_block_for_insn->num_elements 
! 	  || BLOCK_NUM (insn) == 0)
! 	set_block_for_insn (insn, bb);
!       else
! 	break;
!     }
  }
  
  /* Verify the CFG consistency.  This function check some CFG invariants and


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