Clean up edge_def's crossing_edge field

Steven Bosscher stevenb@suse.de
Wed Aug 18 22:29:00 GMT 2004


Hi,

The hot-cold partitioning patch created a little mess  in the
basic-block.h data structures, with the completely unnecessary
crossing_edge field in struct edge_def, and the equally stupid
partition field in struct basic_block_def.

This patch cleans up the first.  Bootstrapped and tested on
amd64.  OK?

Gr.
Steven

	* basic-block.h (struct edge_def): Remove crossing_edge.
	(EDGE_CROSSING): New define.
	(EDGE_ALL_FLAGS): Update.
	* bb-reorder.c (find_traces_1_round, better_edge_p,
	find_rarely_executed_basic_blocks_and_cr, fix_up_fall_thru_edges,
	find_jump_block, fix_crossing_conditional_branches,
	fix_crossing_unconditional_branches, add_reg_crossing_jump_notes):
	Replace all occurences of crossing_edge with an edge flag check
	or set/reset.
	* cfgcleanup.c (try_simplify_condjump, try_forward_edges,
	try_crossjump_bb): Likewise.
	* cfglayout.c (fixup_reorder_chain): Likewise.
	* cfgrtl.c (force_nonfallthru_and_redirect,
	commit_one_edge_insertion): Likewise.

Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.205
diff -c -3 -p -r1.205 basic-block.h
*** basic-block.h	4 Aug 2004 21:37:03 -0000	1.205
--- basic-block.h	18 Aug 2004 21:59:43 -0000
*************** struct edge_def GTY((chain_next ("%h.pre
*** 149,156 ****
    int probability;		/* biased by REG_BR_PROB_BASE */
    gcov_type count;		/* Expected number of executions calculated
  				   in profile.c  */
-   bool crossing_edge;           /* Crosses between hot and cold sections, when
- 				   we do partitioning.  */
  };
  
  typedef struct edge_def *edge;
--- 149,154 ----
*************** typedef struct edge_def *edge;
*** 174,180 ****
  					   predicate is zero.  */
  #define EDGE_EXECUTABLE		4096	/* Edge is executable.  Only
  					   valid during SSA-CCP.  */
! #define EDGE_ALL_FLAGS		8191
  
  #define EDGE_COMPLEX	(EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH)
  
--- 172,181 ----
  					   predicate is zero.  */
  #define EDGE_EXECUTABLE		4096	/* Edge is executable.  Only
  					   valid during SSA-CCP.  */
! #define EDGE_CROSSING		8191    /* Edge crosses between hot
! 					   and cold sections, when we
! 					   do partitioning.  */
! #define EDGE_ALL_FLAGS	       16383
  
  #define EDGE_COMPLEX	(EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH)
  
Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.78
diff -c -3 -p -r1.78 bb-reorder.c
*** bb-reorder.c	18 Aug 2004 16:21:44 -0000	1.78
--- bb-reorder.c	18 Aug 2004 21:59:43 -0000
*************** find_traces_1_round (int branch_th, int 
*** 688,694 ****
  			&& !(e->flags & EDGE_COMPLEX)
  			&& !e->dest->rbi->visited
  			&& !e->dest->pred->pred_next
! 			&& !e->crossing_edge
  			&& e->dest->succ
  			&& (e->dest->succ->flags & EDGE_CAN_FALLTHRU)
  			&& !(e->dest->succ->flags & EDGE_COMPLEX)
--- 688,694 ----
  			&& !(e->flags & EDGE_COMPLEX)
  			&& !e->dest->rbi->visited
  			&& !e->dest->pred->pred_next
! 			&& !(e->flags & EDGE_CROSSING)
  			&& e->dest->succ
  			&& (e->dest->succ->flags & EDGE_CAN_FALLTHRU)
  			&& !(e->dest->succ->flags & EDGE_COMPLEX)
*************** better_edge_p (basic_block bb, edge e, i
*** 880,887 ****
    if (!is_better_edge
        && flag_reorder_blocks_and_partition 
        && cur_best_edge 
!       && cur_best_edge->crossing_edge
!       && !e->crossing_edge)
      is_better_edge = true;
  
    return is_better_edge;
--- 880,887 ----
    if (!is_better_edge
        && flag_reorder_blocks_and_partition 
        && cur_best_edge 
!       && (cur_best_edge->flags & EDGE_CROSSING)
!       && !(e->flags & EDGE_CROSSING))
      is_better_edge = true;
  
    return is_better_edge;
*************** find_rarely_executed_basic_blocks_and_cr
*** 1304,1310 ****
  		&& e->dest != EXIT_BLOCK_PTR
  		&& e->src->partition != e->dest->partition)
  	      {
! 		e->crossing_edge = true;
  		if (i == *max_idx)
  		  {
  		    *max_idx *= 2;
--- 1304,1310 ----
  		&& e->dest != EXIT_BLOCK_PTR
  		&& e->src->partition != e->dest->partition)
  	      {
! 		e->flags |= EDGE_CROSSING;
  		if (i == *max_idx)
  		  {
  		    *max_idx *= 2;
*************** find_rarely_executed_basic_blocks_and_cr
*** 1314,1320 ****
  		crossing_edges[i++] = e;
  	      }
  	    else
! 	      e->crossing_edge = false;
  	  }
      }
    *n_crossing_edges = i;
--- 1314,1320 ----
  		crossing_edges[i++] = e;
  	      }
  	    else
! 	      e->flags &= ~EDGE_CROSSING;
  	  }
      }
    *n_crossing_edges = i;
*************** fix_up_fall_thru_edges (void)
*** 1472,1478 ****
    	{
    	  /* Check to see if the fall-thru edge is a crossing edge.  */
  	
! 	  if (fall_thru->crossing_edge)
    	    {
  	      /* The fall_thru edge crosses; now check the cond jump edge, if
  	         it exists.  */
--- 1472,1478 ----
    	{
    	  /* Check to see if the fall-thru edge is a crossing edge.  */
  	
! 	  if (fall_thru->flags & EDGE_CROSSING)
    	    {
  	      /* The fall_thru edge crosses; now check the cond jump edge, if
  	         it exists.  */
*************** fix_up_fall_thru_edges (void)
*** 1485,1491 ****
  	      
   	      if (cond_jump)
   		{
! 		  if (!cond_jump->crossing_edge)
   		    cond_jump_crosses = false;
  		  
   		  /* We know the fall-thru edge crosses; if the cond
--- 1485,1491 ----
  	      
   	      if (cond_jump)
   		{
! 		  if (!(cond_jump->flags & EDGE_CROSSING))
   		    cond_jump_crosses = false;
  		  
   		  /* We know the fall-thru edge crosses; if the cond
*************** fix_up_fall_thru_edges (void)
*** 1513,1520 ****
   			  e = fall_thru;
   			  fall_thru = cond_jump;
   			  cond_jump = e;
! 			  cond_jump->crossing_edge = true;
! 			  fall_thru->crossing_edge = false;
   			}
   		    }
   		}
--- 1513,1520 ----
   			  e = fall_thru;
   			  fall_thru = cond_jump;
   			  cond_jump = e;
! 			  cond_jump->flags |= EDGE_CROSSING;
! 			  fall_thru->flags &= ~EDGE_CROSSING;
   			}
   		    }
   		}
*************** fix_up_fall_thru_edges (void)
*** 1537,1543 ****
  			 partition as bb it's falling through from.  */
   		      
  		      new_bb->partition = cur_bb->partition;
! 		      new_bb->succ->crossing_edge = true;
   		    }
  		  
   		  /* Add barrier after new jump */
--- 1537,1543 ----
  			 partition as bb it's falling through from.  */
   		      
  		      new_bb->partition = cur_bb->partition;
! 		      new_bb->succ->flags |= EDGE_CROSSING;
   		    }
  		  
   		  /* Add barrier after new jump */
*************** find_jump_block (basic_block jump_dest) 
*** 1574,1580 ****
    rtx insn;
  
    for (e = jump_dest->pred; e; e = e->pred_next)
!     if (e->crossing_edge)
        {
  	basic_block src = e->src;
  	
--- 1574,1580 ----
    rtx insn;
  
    for (e = jump_dest->pred; e; e = e->pred_next)
!     if (e->flags & EDGE_CROSSING)
        {
  	basic_block src = e->src;
  	
*************** fix_crossing_conditional_branches (void)
*** 1643,1651 ****
        /* We already took care of fall-through edges, so only one successor
  	 can be a crossing edge.  */
        
!       if (succ1 && succ1->crossing_edge)
  	crossing_edge = succ1;
!       else if (succ2 && succ2->crossing_edge)
   	crossing_edge = succ2;
        
        if (crossing_edge) 
--- 1643,1651 ----
        /* We already took care of fall-through edges, so only one successor
  	 can be a crossing edge.  */
        
!       if (succ1 && (succ1->flags & EDGE_CROSSING))
  	crossing_edge = succ1;
!       else if (succ2 && (succ2->flags & EDGE_CROSSING))
   	crossing_edge = succ2;
        
        if (crossing_edge) 
*************** fix_crossing_conditional_branches (void)
*** 1758,1765 ****
  	      else
  		new_edge = new_bb->succ;
  	      
! 	      crossing_edge->crossing_edge = false;
! 	      new_edge->crossing_edge = true;
  	    }
   	}
      }
--- 1758,1765 ----
  	      else
  		new_edge = new_bb->succ;
  	      
! 	      crossing_edge->flags &= ~EDGE_CROSSING;
! 	      new_edge->flags |= EDGE_CROSSING;
  	    }
   	}
      }
*************** fix_crossing_unconditional_branches (voi
*** 1790,1796 ****
           this point, no crossing jumps should be conditional.  */
  
        if (JUMP_P (last_insn)
! 	  && succ->crossing_edge)
  	{
  	  rtx label2, table;
  
--- 1790,1796 ----
           this point, no crossing jumps should be conditional.  */
  
        if (JUMP_P (last_insn)
! 	  && (succ->flags & EDGE_CROSSING))
  	{
  	  rtx label2, table;
  
*************** add_reg_crossing_jump_notes (void)
*** 1858,1864 ****
  
    FOR_EACH_BB (bb)
      for (e = bb->succ; e; e = e->succ_next)
!       if (e->crossing_edge
  	  && JUMP_P (BB_END (e->src)))
  	REG_NOTES (BB_END (e->src)) = gen_rtx_EXPR_LIST (REG_CROSSING_JUMP, 
  							 NULL_RTX, 
--- 1858,1864 ----
  
    FOR_EACH_BB (bb)
      for (e = bb->succ; e; e = e->succ_next)
!       if ((e->flags & EDGE_CROSSING)
  	  && JUMP_P (BB_END (e->src)))
  	REG_NOTES (BB_END (e->src)) = gen_rtx_EXPR_LIST (REG_CROSSING_JUMP, 
  							 NULL_RTX, 
Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgcleanup.c,v
retrieving revision 1.124
diff -c -3 -p -r1.124 cfgcleanup.c
*** cfgcleanup.c	18 Aug 2004 16:21:48 -0000	1.124
--- cfgcleanup.c	18 Aug 2004 21:59:44 -0000
*************** try_simplify_condjump (basic_block cbran
*** 154,160 ****
  
    if (flag_reorder_blocks_and_partition
        && (jump_block->partition != jump_dest_block->partition
! 	  || cbranch_jump_edge->crossing_edge))
      return false;
  
    /* The conditional branch must target the block after the
--- 154,160 ----
  
    if (flag_reorder_blocks_and_partition
        && (jump_block->partition != jump_dest_block->partition
! 	  || (cbranch_jump_edge->flags & EDGE_CROSSING)))
      return false;
  
    /* The conditional branch must target the block after the
*************** try_forward_edges (int mode, basic_block
*** 461,467 ****
  	  may_thread |= target->flags & BB_DIRTY;
  
  	  if (FORWARDER_BLOCK_P (target)
! 	      && !target->succ->crossing_edge
  	      && target->succ->dest != EXIT_BLOCK_PTR)
  	    {
  	      /* Bypass trivial infinite loops.  */
--- 461,467 ----
  	  may_thread |= target->flags & BB_DIRTY;
  
  	  if (FORWARDER_BLOCK_P (target)
! 	      && !(target->succ->flags & EDGE_CROSSING)
  	      && target->succ->dest != EXIT_BLOCK_PTR)
  	    {
  	      /* Bypass trivial infinite loops.  */
*************** try_crossjump_bb (int mode, basic_block 
*** 1674,1680 ****
    
    if (flag_reorder_blocks_and_partition
        && (bb->pred->src->partition != bb->pred->pred_next->src->partition
! 	  || bb->pred->crossing_edge))
      return false;
  
    /* It is always cheapest to redirect a block that ends in a branch to
--- 1674,1680 ----
    
    if (flag_reorder_blocks_and_partition
        && (bb->pred->src->partition != bb->pred->pred_next->src->partition
! 	  || (bb->pred->flags & EDGE_CROSSING)))
      return false;
  
    /* It is always cheapest to redirect a block that ends in a branch to
Index: cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.69
diff -c -3 -p -r1.69 cfglayout.c
*** cfglayout.c	18 Aug 2004 16:21:49 -0000	1.69
--- cfglayout.c	18 Aug 2004 21:59:45 -0000
*************** fixup_reorder_chain (void)
*** 723,729 ****
  
  	      /* If the "jumping" edge is a crossing edge, and the fall
  		 through edge is non-crossing, leave things as they are.  */
! 	      else if (e_taken->crossing_edge && !e_fall->crossing_edge)
  		continue;
  
  	      /* Otherwise we can try to invert the jump.  This will
--- 723,730 ----
  
  	      /* If the "jumping" edge is a crossing edge, and the fall
  		 through edge is non-crossing, leave things as they are.  */
! 	      else if ((e_taken->flags & EDGE_CROSSING)
! 		       && !(e_fall->flags & EDGE_CROSSING))
  		continue;
  
  	      /* Otherwise we can try to invert the jump.  This will
*************** fixup_reorder_chain (void)
*** 814,820 ****
  		}
  	      if (JUMP_P (BB_END (bb))
  		  && !any_condjump_p (BB_END (bb))
! 		  && bb->succ->crossing_edge )
  		REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST 
  		  (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
  	    }
--- 815,821 ----
  		}
  	      if (JUMP_P (BB_END (bb))
  		  && !any_condjump_p (BB_END (bb))
! 		  && (bb->succ->flags & EDGE_CROSSING))
  		REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST 
  		  (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
  	    }
Index: cfgrtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgrtl.c,v
retrieving revision 1.127
diff -c -3 -p -r1.127 cfgrtl.c
*** cfgrtl.c	18 Aug 2004 16:21:49 -0000	1.127
--- cfgrtl.c	18 Aug 2004 21:59:46 -0000
*************** force_nonfallthru_and_redirect (edge e, 
*** 1114,1120 ****
  	    }
  	  if (JUMP_P (BB_END (jump_block))
  	      && !any_condjump_p (BB_END (jump_block))
! 	      && jump_block->succ->crossing_edge )
  	    REG_NOTES (BB_END (jump_block)) = gen_rtx_EXPR_LIST 
  	      (REG_CROSSING_JUMP, NULL_RTX, 
  	       REG_NOTES (BB_END (jump_block)));
--- 1114,1120 ----
  	    }
  	  if (JUMP_P (BB_END (jump_block))
  	      && !any_condjump_p (BB_END (jump_block))
! 	      && (jump_block->succ->flags & EDGE_CROSSING))
  	    REG_NOTES (BB_END (jump_block)) = gen_rtx_EXPR_LIST 
  	      (REG_CROSSING_JUMP, NULL_RTX, 
  	       REG_NOTES (BB_END (jump_block)));
*************** commit_one_edge_insertion (edge e, int w
*** 1602,1608 ****
  	      && targetm.have_named_sections
  	      && e->src != ENTRY_BLOCK_PTR
  	      && e->src->partition == COLD_PARTITION
! 	      && !e->crossing_edge)
  	    {
  	      rtx bb_note, new_note, cur_insn;
  
--- 1602,1608 ----
  	      && targetm.have_named_sections
  	      && e->src != ENTRY_BLOCK_PTR
  	      && e->src->partition == COLD_PARTITION
! 	      && !(e->flags & EDGE_CROSSING))
  	    {
  	      rtx bb_note, new_note, cur_insn;
  
*************** commit_one_edge_insertion (edge e, int w
*** 1621,1627 ****
  	      NOTE_BASIC_BLOCK (new_note) = bb;
  	      if (JUMP_P (BB_END (bb))
  		  && !any_condjump_p (BB_END (bb))
! 		  && bb->succ->crossing_edge )
  		REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST 
  		  (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
  	      if (after == bb_note)
--- 1621,1627 ----
  	      NOTE_BASIC_BLOCK (new_note) = bb;
  	      if (JUMP_P (BB_END (bb))
  		  && !any_condjump_p (BB_END (bb))
! 		  && (bb->succ->flags & EDGE_CROSSING))
  		REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST 
  		  (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
  	      if (after == bb_note)
*************** rtl_verify_flow_info_1 (void)
*** 1986,1992 ****
  	  if (e->flags & EDGE_FALLTHRU)
  	    {
  	      n_fallthru++, fallthru = e;
! 	      if (e->crossing_edge
  		  || (e->src->partition != e->dest->partition
  		      && e->src != ENTRY_BLOCK_PTR
  		      && e->dest != EXIT_BLOCK_PTR))
--- 1986,1992 ----
  	  if (e->flags & EDGE_FALLTHRU)
  	    {
  	      n_fallthru++, fallthru = e;
! 	      if ((e->flags & EDGE_CROSSING)
  		  || (e->src->partition != e->dest->partition
  		      && e->src != ENTRY_BLOCK_PTR
  		      && e->dest != EXIT_BLOCK_PTR))



More information about the Gcc-patches mailing list