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] More infrastructure for dominator improvements


I forgot about this one in my last patch.

Basically this doesn't change the behavior of the compiler at all.  It
merely factors some code out of remove_bb that I'm going to need
elsewhere (specifically the code to remove PHI nodes and edges from
basic blocks -- without expunging basic blocks).

This has also been bootstrapped and regression tested.



	* tree-flow.h (remove_phi_nodes_and_edges_for_unreachable_block):
	Prototype.
	* tree-cfg.c (remove_phi_nodes_and_edges_for_unreachable_block): New
	function extracted from remove_bb.
	(remove_bb): Call remove_phi_nodes_and_edges_for_unreachable_block.

Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.92
diff -c -3 -p -r1.1.4.92 tree-flow.h
*** tree-flow.h	15 Jul 2003 19:15:25 -0000	1.1.4.92
--- tree-flow.h	17 Jul 2003 20:23:59 -0000
*************** extern void debug_cfg_stats (void);
*** 400,405 ****
--- 400,406 ----
  extern void tree_cfg2dot (FILE *);
  extern void insert_bb_before (basic_block, basic_block);
  extern void cleanup_tree_cfg (void);
+ extern void remove_phi_nodes_and_edges_for_unreachable_block (basic_block);
  extern tree first_stmt (basic_block);
  extern tree last_stmt (basic_block);
  extern tree *last_stmt_ptr (basic_block);
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.129
diff -c -3 -p -r1.1.4.129 tree-cfg.c
*** tree-cfg.c	17 Jul 2003 01:13:17 -0000	1.1.4.129
--- tree-cfg.c	17 Jul 2003 20:24:06 -0000
*************** remove_unreachable_block (basic_block bb
*** 1764,1769 ****
--- 1764,1797 ----
  }
  
  
+ /* Remove PHI nodes associated with basic block BB and all edges into
+    and out of BB.  */
+ void
+ remove_phi_nodes_and_edges_for_unreachable_block (basic_block bb)
+ {
+   /* Remove the edges into and out of this block.  */
+   while (bb->pred != NULL)
+     {
+       tree phi;
+ 
+       /* Since this block is no longer reachable, we can just delete all
+          of its PHI nodes.  */
+       phi = phi_nodes (bb);
+       while (phi)
+         {
+ 	  tree next = TREE_CHAIN (phi);
+ 	  remove_phi_node (phi, NULL_TREE, bb);
+ 	  phi = next;
+         }
+ 
+       remove_edge (bb->pred);
+     }
+ 
+   /* Remove edges to BB's successors.  */
+   while (bb->succ != NULL)
+     ssa_remove_edge (bb->succ);
+ }
+ 
  /* Remove block BB and its statements from the flowgraph.  REMOVE_STMTS is
     nonzero if the statements in BB should also be removed.
  
*************** remove_bb (basic_block bb, int remove_st
*** 1820,1849 ****
    if (bb->end_tree_p)
      set_bb_for_stmt (*bb->end_tree_p, NULL);
  
!   /* Remove the edges into and out of this block.  */
!   while (bb->pred != NULL)
!     {
!       tree phi;
! 
!       /* Since this block is no longer reachable, we can just delete all
!          of its PHI nodes.  */
!       phi = phi_nodes (bb);
!       while (phi)
!         {
! 	  tree next = TREE_CHAIN (phi);
! 	  remove_phi_node (phi, NULL_TREE, bb);
! 	  phi = next;
!         }
! 
!       remove_edge (bb->pred);
!     }
! 
!   /* Remove edges to BB's successors.  */
!   while (bb->succ != NULL)
!     ssa_remove_edge (bb->succ);
! 
!   bb->pred = NULL;
!   bb->succ = NULL;
  
    /* If we have pdom information, then we must also make sure to
       clean up the dominance information.  */
--- 1848,1854 ----
    if (bb->end_tree_p)
      set_bb_for_stmt (*bb->end_tree_p, NULL);
  
!   remove_phi_nodes_and_edges_for_unreachable_block (bb);
  
    /* If we have pdom information, then we must also make sure to
       clean up the dominance information.  */





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