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]

[patch] tree-flow-inline.h: Remove phi_arg_from_edge.


Hi,

Attached is a patch to remove phi_arg_from_edge and replace all uses
of it with E->dest_idx.

Before PHI nodes got lined up with edge vectors, phi_arg_from_edge
used to compute an index of a PHI argument within a PHI node.
Nowadays, the index is a function of an edge but not a PHI node, so it
doesn't make sense for phi_arg_from_edge to take a PHI node as an
argument or use gcc_assert on it.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2005-01-22  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-flow-inline.h (phi_arg_from_edge): Remove.
	* tree-flow.h: Remove the corresponding prototype.
	* tree-ssa-operands.h, tree-ssa-threadupdate.c, tree-ssa.c,
	tree-vectorizer.c: Use dest_idx instead of phi_arg_from_edge.

Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow-inline.h,v
retrieving revision 2.28
diff -u -d -p -r2.28 tree-flow-inline.h
--- tree-flow-inline.h	20 Dec 2004 18:18:28 -0000	2.28
+++ tree-flow-inline.h	21 Jan 2005 09:12:37 -0000
@@ -389,15 +389,6 @@ set_phi_nodes (basic_block bb, tree l)
     set_bb_for_stmt (phi, bb);
 }
 
-/* Return the phi index number for an edge.  */
-static inline int
-phi_arg_from_edge (tree phi, edge e)
-{
-  gcc_assert (phi);
-  gcc_assert (TREE_CODE (phi) == PHI_NODE);
-  return e->dest_idx;
-}
-
 /* Mark VAR as used, so that it'll be preserved during rtl expansion.  */
 
 static inline void
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.77
diff -u -d -p -r2.77 tree-flow.h
--- tree-flow.h	18 Jan 2005 11:36:24 -0000	2.77
+++ tree-flow.h	21 Jan 2005 09:12:38 -0000
@@ -698,7 +698,6 @@ enum move_pos
 extern enum move_pos movement_possibility (tree);
 
 /* In tree-flow-inline.h  */
-static inline int phi_arg_from_edge (tree, edge);
 static inline bool is_call_clobbered (tree);
 static inline void mark_call_clobbered (tree);
 static inline void set_is_used (tree);
Index: tree-ssa-operands.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-operands.h,v
retrieving revision 2.9
diff -u -d -p -r2.9 tree-ssa-operands.h
--- tree-ssa-operands.h	25 Nov 2004 20:24:59 -0000	2.9
+++ tree-ssa-operands.h	21 Jan 2005 09:12:38 -0000
@@ -175,11 +175,9 @@ typedef stmt_operands_t *stmt_operands_p
 #define SET_PHI_ARG_DEF(PHI, I, V)					\
 				SET_USE (PHI_ARG_DEF_PTR ((PHI), (I)), (V))
 #define PHI_ARG_DEF_FROM_EDGE(PHI, E)					\
-				PHI_ARG_DEF ((PHI),			\
-					     phi_arg_from_edge ((PHI),(E)))
+				PHI_ARG_DEF ((PHI), (E)->dest_idx)
 #define PHI_ARG_DEF_PTR_FROM_EDGE(PHI, E)				\
-				PHI_ARG_DEF_PTR ((PHI), 		\
-					     phi_arg_from_edge ((PHI),(E)))
+				PHI_ARG_DEF_PTR ((PHI), (E)->dest_idx)
 
 
 extern void init_ssa_operands (void);
Index: tree-ssa-threadupdate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-threadupdate.c,v
retrieving revision 2.18
diff -u -d -p -r2.18 tree-ssa-threadupdate.c
--- tree-ssa-threadupdate.c	25 Nov 2004 22:31:09 -0000	2.18
+++ tree-ssa-threadupdate.c	21 Jan 2005 09:12:38 -0000
@@ -298,7 +298,7 @@ create_edge_and_update_destination_phis 
      associated with the outgoing edge stored in RD.  */
   for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
     {
-      int indx = phi_arg_from_edge (phi, rd->outgoing_edge);
+      int indx = rd->outgoing_edge->dest_idx;
       add_phi_arg (phi, PHI_ARG_DEF_TREE (phi, indx), e);
     }
 }
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.72
diff -u -d -p -r2.72 tree-ssa.c
--- tree-ssa.c	18 Jan 2005 11:36:29 -0000	2.72
+++ tree-ssa.c	21 Jan 2005 09:12:39 -0000
@@ -56,18 +56,16 @@ ssa_redirect_edge (edge e, basic_block d
   tree phi, next;
   tree list = NULL, *last = &list;
   tree src, dst, node;
-  int i;
 
   /* Remove the appropriate PHI arguments in E's destination block.  */
   for (phi = phi_nodes (e->dest); phi; phi = next)
     {
       next = PHI_CHAIN (phi);
 
-      i = phi_arg_from_edge (phi, e);
-      if (PHI_ARG_DEF (phi, i) == NULL_TREE)
+      if (PHI_ARG_DEF (phi, e->dest_idx) == NULL_TREE)
 	continue;
 
-      src = PHI_ARG_DEF (phi, i);
+      src = PHI_ARG_DEF (phi, e->dest_idx);
       dst = PHI_RESULT (phi);
       node = build_tree_list (dst, src);
       *last = node;
Index: tree-vectorizer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vectorizer.c,v
retrieving revision 2.62
diff -u -d -p -r2.62 tree-vectorizer.c
--- tree-vectorizer.c	18 Jan 2005 11:36:29 -0000	2.62
+++ tree-vectorizer.c	21 Jan 2005 09:12:43 -0000
@@ -523,7 +523,7 @@ slpeel_update_phis_for_duplicate_loop (s
         {
           gcc_assert (new_loop_exit_e == orig_entry_e);
           SET_PHI_ARG_DEF (phi_orig,
-                           phi_arg_from_edge (phi_orig, new_loop_exit_e),
+                           new_loop_exit_e->dest_idx,
                            new_ssa_name);
         }
     }
@@ -639,8 +639,7 @@ slpeel_update_phi_nodes_for_guard (edge 
       /* 3. Update phi in successor block.  */
       gcc_assert (PHI_ARG_DEF_FROM_EDGE (update_phi, e) == loop_arg
                   || PHI_ARG_DEF_FROM_EDGE (update_phi, e) == guard_arg);
-      SET_PHI_ARG_DEF (update_phi, phi_arg_from_edge (update_phi, e),
-                       PHI_RESULT (new_phi));
+      SET_PHI_ARG_DEF (update_phi, e->dest_idx, PHI_RESULT (new_phi));
     }
 
   set_phi_nodes (new_merge_bb, phi_reverse (phi_nodes (new_merge_bb)));
@@ -3188,7 +3187,7 @@ vect_update_ivs_after_vectorizer (struct
       /* Fix phi expressions in the successor bb.  */
       gcc_assert (PHI_ARG_DEF_FROM_EDGE (phi1, update_e) ==
                   PHI_ARG_DEF_FROM_EDGE (phi, EDGE_SUCC (loop->latch, 0)));
-      SET_PHI_ARG_DEF (phi1, phi_arg_from_edge (phi1, update_e), ni_name);
+      SET_PHI_ARG_DEF (phi1, update_e->dest_idx, ni_name);
     }
 }
 


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