This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa-branch] Store edges in PHI arguments [patch]
- From: Diego Novillo <dnovillo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 26 Aug 2002 20:14:09 -0400
- Subject: [tree-ssa-branch] Store edges in PHI arguments [patch]
- Organization: Red Hat Canada
This patch removes the last call to find_edges in tree-ssa-ccp.c.
Together with the addition of the executable flag to edges, we
now process insn-*.c in a fraction of the time it used to take
(<1 CPU minute instead of +80). This coupled with the tweak to
cache immediate dominators means that bootstraps are not taking
forever on the branch anymore. We're down to ~2800 seconds
instead of ~4100.
PHI arguments are separate structures now. Each PHI argument
knows which definition reaches it and from which incoming edge.
The patch also adds a few helpers to deal with PHI arguments.
For those who have transformations in their local trees. The
patch breaks some interfaces. Particularly those dealing with
PHI arguments. I've fixed all the interfaces for stuff that was
checked in the branch.
Bootstrapped and regtested on x86. I'm still not enabling
tree-ssa-ccp by default. We are still getting a comparison
failure in emit-insn.o.
Diego.
* Makefile.in (tree-ssa.o): Add dependency on ggc.h
(c-simplify.o): Add dependency on langhooks-def.h
* c-simplify.c: Include langhooks-def.h
(simplify_function_tree): Do nothing if the front end does not
support simplification.
* tree-flow.h (struct vardef): Remove fields 'phi_chain' and
'phi_chain_bb'.
Add field 'phi_args'.
(VARDEF_PHI_CHAIN): Remove. Update all users.
(VARDEF_PHI_CHAIN_BB): Remove. Update all users.
(VARDEF_PHI_ARGS): Define.
(struct varuse): Rename field 'chain' to 'imm_rdef'. Update all
users.
(VARUSE_IMM_RDEF): Rename from VARUSE_CHAIN. Update all users.
(phi_arg): New structure.
(get_num_phi_args): New function.
(get_phi_arg): New function.
(set_phi_arg): New function.
(add_phi_arg): New function.
(debug_phi_args): Declare.
(dump_phi_args): Declare.
* tree-dfa.c (create_ref): Remove initialization of
VARDEF_PHI_CHAIN and VARDEF_PHI_CHAIN_BB.
Initialize array VARDEF_PHI_ARGS.
(dump_varref): Call dump_phi_args.
(dump_phi_args): New function.
(debug_phi_args): New function.
* tree-ssa-ccp.c (PHI_PARMS): Remove.
(EIE): Remove.
(visit_phi_node): Get the argument's edge directly from the
argument instead of calling find_edge.
(initialize): Cast call to NUM_EDGES to unsigned.
* tree-ssa-pre.c: Update uses of VARDEF_PHI_CHAIN,
VARDEF_PHI_CHAIN_BB and VARUSE_CHAIN everywhere.
* tree-ssa.c: Ditto.
Include ggc.h.
(search_fud_chains): Call add_phi_arg to add arguments to each PHI
node.
(tree_ssa_remove_phi_alternative): Call set_phi_arg to switch the
last element with the element being removed.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.19
diff -d -u -p -r1.903.2.19 Makefile.in
--- Makefile.in 26 Aug 2002 01:34:48 -0000 1.903.2.19
+++ Makefile.in 26 Aug 2002 23:20:28 -0000
@@ -1393,7 +1393,7 @@ tree-alias-steen.o: tree-alias-steen.c t
$(CONFIG_H) $(GGC_H) $(TREE_H) gt-tree-alias-steen.h tree-flow.h
tree-ssa.o : tree-ssa.c tree-optimize.h tree-flow.h $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(BASIC_BLOCK_H) $(EXPR_H) $(C_COMMON_H) \
- $(GGC_H) output.h diagnostic.h ssa.h errors.h toplev.h
+ $(GGC_H) output.h diagnostic.h ssa.h errors.h toplev.h ggc.h
tree-ssa-pre.o : tree-ssa-pre.c tree-optimize.h tree-flow.h $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(BASIC_BLOCK_H) $(EXPR_H) \
$(C_COMMON_H) $(GGC_H) output.h diagnostic.h ssa.h errors.h toplev.h
@@ -1409,7 +1409,7 @@ tree-optimize.o : tree-optimize.c tree-o
tree-dchain.h
c-simplify.o : c-simplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \
$(C_TREE_H) $(C_COMMON_H) diagnostic.h tree-simple.h varray.h flags.h \
- langhooks.h toplev.h rtl.h tree-flow.h $(BASIC_BLOCK_H)
+ langhooks.h toplev.h rtl.h tree-flow.h $(BASIC_BLOCK_H) langhooks-def.h
simple-break-elim.o : simple-break-elim.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
$(C_TREE_H) $(C_COMMON_H) diagnostic.h tree-dchain.h
simple-goto-elim.o : simple-goto-elim.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
Index: c-simplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/c-simplify.c,v
retrieving revision 1.1.4.19
diff -d -u -p -r1.1.4.19 c-simplify.c
--- c-simplify.c 26 Aug 2002 13:36:42 -0000 1.1.4.19
+++ c-simplify.c 26 Aug 2002 23:20:28 -0000
@@ -38,6 +38,7 @@ Software Foundation, 59 Temple Place - S
#include "tree-inline.h"
#include "diagnostic.h"
#include "langhooks.h"
+#include "langhooks-def.h"
#include "flags.h"
#include "rtl.h"
#include "toplev.h"
@@ -127,6 +128,11 @@ simplify_function_tree (fndecl)
if (errorcount || sorrycount)
return 0;
+ /* FIXME. Hack. If this front end does not support simplification,
+ do nothing. */
+ if (lang_hooks.simplify_expr == lhd_simplify_expr)
+ return 0;
+
fntree = DECL_SAVED_TREE (fndecl);
if (fntree == NULL_TREE || TREE_CODE (fntree) != COMPOUND_STMT)
return 0;
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.10
diff -d -u -p -r1.1.4.10 tree-dfa.c
--- tree-dfa.c 26 Aug 2002 01:34:54 -0000 1.1.4.10
+++ tree-dfa.c 26 Aug 2002 23:20:29 -0000
@@ -673,10 +673,7 @@ create_ref (sym, ref_type, bb, parent_st
VARDEF_IMM_USES (ref) = create_ref_list ();
VARDEF_RUSES (ref) = create_ref_list ();
if (ref_type == VARPHI)
- {
- VARRAY_GENERIC_PTR_INIT (VARDEF_PHI_CHAIN (ref), 3, "phi_chain");
- VARRAY_BB_INIT (VARDEF_PHI_CHAIN_BB (ref), 3, "phi_chain_bb");
- }
+ VARRAY_GENERIC_PTR_INIT (VARDEF_PHI_ARGS (ref), 3, "phi_args");
}
else if (ref_type == VARUSE)
VARUSE_RDEFS (ref) = create_ref_list ();
@@ -969,11 +966,11 @@ dump_varref (outf, prefix, ref, indent,
{
if (VARREF_TYPE (ref) == VARPHI)
{
- if (VARDEF_PHI_CHAIN (ref))
+ if (VARDEF_PHI_ARGS (ref))
{
fputs (" phi-args:\n", outf);
- dump_varref_array (outf, prefix, VARDEF_PHI_CHAIN (ref),
- indent + 4, 0);
+ dump_phi_args (outf, prefix, VARDEF_PHI_ARGS (ref), indent + 4,
+ 0);
}
if (VARDEF_IMM_USES (ref))
@@ -998,10 +995,10 @@ dump_varref (outf, prefix, ref, indent,
dump_varref_list (outf, prefix, VARDEF_IMM_USES (ref), indent + 4,
0);
}
- else if (VARREF_TYPE (ref) == VARUSE && VARUSE_CHAIN (ref))
+ else if (VARREF_TYPE (ref) == VARUSE && VARUSE_IMM_RDEF (ref))
{
- fputs (" reaching def:\n", outf);
- dump_varref (outf, prefix, VARUSE_CHAIN (ref), indent + 4, 0);
+ fputs (" immediate reaching def:\n", outf);
+ dump_varref (outf, prefix, VARUSE_IMM_RDEF (ref), indent + 4, 0);
}
else if (VARREF_TYPE (ref) == EXPRUSE && EXPRUSE_PHIOP (ref) == 1)
{
@@ -1082,6 +1079,30 @@ dump_varref_array (outf, prefix, reflist
indent, details);
}
+/* Display a list of PHI arguments on stream OUTF. PREFIX is a
+ string that is prefixed to every line of output, and INDENT is the
+ amount of left margin to leave. If DETAILS is nonzero, the output is
+ more verbose. */
+
+void
+dump_phi_args (outf, prefix, reflist, indent, details)
+ FILE *outf;
+ const char *prefix;
+ varray_type reflist;
+ int indent;
+ int details;
+{
+ size_t i;
+
+ if (reflist == NULL)
+ return;
+
+ for (i = 0; i < VARRAY_SIZE (reflist); i++)
+ if (VARRAY_GENERIC_PTR (reflist, i))
+ dump_varref (outf, prefix,
+ ((phi_arg)VARRAY_GENERIC_PTR (reflist, i))->def,
+ indent, details);
+}
/* Dump REFLIST on stderr. */
@@ -1100,4 +1121,14 @@ debug_varref_array (reflist)
varray_type reflist;
{
dump_varref_array (stderr, "", reflist, 0, 1);
+}
+
+
+/* Dump ARGLIST on stderr. */
+
+void
+debug_phi_args (arglist)
+ varray_type arglist;
+{
+ dump_phi_args (stderr, "", arglist, 0, 1);
}
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.9
diff -d -u -p -r1.1.4.9 tree-flow.h
--- tree-flow.h 23 Aug 2002 16:52:58 -0000 1.1.4.9
+++ tree-flow.h 26 Aug 2002 23:20:29 -0000
@@ -149,36 +149,31 @@ struct vardef
/* Visited mark. Used when computing reaching definitions. */
union varref_def *marked;
- /* PHI arguments (not used with real definitions). */
- varray_type phi_chain;
-
- /* PHI argument's BB. This field indicates the basic block that this
- argument is reaching us from. It does *not* indicate which block this
- argument is *in*. */
- varray_type phi_chain_bb;
+ /* PHI arguments (not used with real definitions). The number of
+ arguments to a PHI node is the number of incoming edges to the basic
+ block where that PHI node resides. Each argument is of type phi_arg. */
+ varray_type phi_args;
};
#define VARDEF_IMM_USES(r) (r)->def.imm_uses
#define VARDEF_SAVE_CHAIN(r) (r)->def.save_chain
#define VARDEF_RUSES(r) (r)->def.ruses
#define VARDEF_MARKED(r) (r)->def.marked
-#define VARDEF_PHI_CHAIN(r) (r)->def.phi_chain
-#define VARDEF_PHI_CHAIN_BB(r) (r)->def.phi_chain_bb
-
+#define VARDEF_PHI_ARGS(r) (r)->def.phi_args
/* Variable uses. */
struct varuse
{
struct exprref_common common;
- /* Definition chain (immediate reaching definition). */
- union varref_def *chain;
+ /* Immediate reaching definition for this use. */
+ union varref_def *imm_rdef;
/* Definitions reaching this use. */
ref_list rdefs;
};
-#define VARUSE_CHAIN(r) (r)->use.chain
+#define VARUSE_IMM_RDEF(r) (r)->use.imm_rdef
#define VARUSE_RDEFS(r) (r)->use.rdefs
@@ -234,6 +229,23 @@ typedef union varref_def *varref;
#define EXPRREF_SAVE(r) (r)->ecommon.save
#define EXPRREF_RELOAD(r) (r)->ecommon.reload
+
+/* PHI node arguments. */
+typedef struct
+{
+ /* Definition reaching this argument. */
+ varref def;
+
+ /* Incoming edge where DEF is coming from. */
+ edge e;
+} *phi_arg;
+
+static inline unsigned get_num_phi_args PARAMS ((varref));
+static inline phi_arg get_phi_arg PARAMS ((varref, unsigned int));
+static inline void set_phi_arg PARAMS ((varref, unsigned int, phi_arg));
+extern void add_phi_arg PARAMS ((varref, varref, edge));
+
+
/* Return nonzero if R is a default definition. Default definitions are
artificially created in the first basic block of the program. They
provide a convenient way of checking if a variable is used without being
@@ -260,8 +272,9 @@ struct tree_ann_def
basic_block bb;
/* For _DECL trees, list of references made to this variable. For _STMT
- trees, list of references made in this statement. For any other
- SIMPLE expression, list of references made in this expression. */
+ trees, list of references made in this statement. For first-level
+ SIMPLE expressions (i.e., the topmost expression of a _STMT node),
+ list of references made in this expression. */
ref_list refs;
/* For _DECL trees this is the most recent definition for this symbol.
@@ -443,10 +456,13 @@ extern void debug_varref PARAMS ((varref
extern void dump_varref PARAMS ((FILE *, const char *, varref, int, int));
extern void debug_varref_list PARAMS ((ref_list));
extern void debug_varref_array PARAMS ((varray_type));
+extern void debug_phi_args PARAMS ((varray_type));
extern void dump_varref_list PARAMS ((FILE *, const char *, ref_list, int,
int));
extern void dump_varref_array PARAMS ((FILE *, const char *, varray_type, int,
int));
+extern void dump_phi_args PARAMS ((FILE *, const char *, varray_type, int,
+ int));
extern int function_may_recurse_p PARAMS ((void));
extern void get_fcalls PARAMS ((varray_type *, unsigned));
extern basic_block find_declaration PARAMS ((tree));
@@ -463,5 +479,41 @@ extern void tree_ssa_remove_phi_alternat
/* Functions in tree-alias-steen.c */
extern void create_alias_vars PARAMS ((void));
+
+
+/* Inline functions. */
+
+/* Return the number of arguments for PHI. */
+
+static inline unsigned
+get_num_phi_args (phi)
+ varref phi;
+{
+ return VARRAY_ACTIVE_SIZE (VARDEF_PHI_ARGS (phi));
+}
+
+
+/* Return the Ith argument of PHI. Each PHI argument contains a VARDEF and
+ an edge where that VARDEF is coming from. */
+
+static inline phi_arg
+get_phi_arg (phi, i)
+ varref phi;
+ unsigned int i;
+{
+ return (phi_arg)(VARRAY_GENERIC_PTR (VARDEF_PHI_ARGS (phi), i));
+}
+
+
+/* Set the Ith argument of PHI to be ARG. */
+
+static inline void
+set_phi_arg (phi, i, arg)
+ varref phi;
+ unsigned int i;
+ phi_arg arg;
+{
+ VARRAY_GENERIC_PTR (VARDEF_PHI_ARGS (phi), i) = (PTR)arg;
+}
#endif /* _TREE_FLOW_H */
Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.13
diff -d -u -p -r1.1.2.13 tree-ssa-ccp.c
--- tree-ssa-ccp.c 23 Aug 2002 17:21:15 -0000 1.1.2.13
+++ tree-ssa-ccp.c 26 Aug 2002 23:20:29 -0000
@@ -106,10 +106,6 @@ static struct edge_list *edges;
nodes that need to be visited are accessed using VARDEF_IMM_USES (D). */
ref_list ssa_edges;
-/* Simple macros to simplify code. */
-#define PHI_PARMS(x) VARDEF_PHI_CHAIN (x)
-#define EIE(x,y) EDGE_INDEX (edges, x, y)
-
static void initialize PARAMS ((void));
static void finalize PARAMS ((void));
static void visit_phi_node PARAMS ((varref));
@@ -379,7 +375,7 @@ ssa_ccp_substitute_constants ()
if (VARREF_TYPE (ref) != VARUSE)
continue;
- rdef = VARUSE_CHAIN (ref);
+ rdef = VARUSE_IMM_RDEF (ref);
id = VARREF_ID (rdef);
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -468,8 +464,7 @@ visit_phi_node (phi_node)
unsigned int phi_node_name = VARREF_ID (phi_node);
latticevalue phi_node_lattice_val = UNDEFINED;
- varray_type phi_vec = PHI_PARMS (phi_node);
- unsigned int num_elem = VARRAY_ACTIVE_SIZE (phi_vec);
+ unsigned int num_elem = get_num_phi_args (phi_node);
tree phi_node_expr = NULL;
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -477,34 +472,28 @@ visit_phi_node (phi_node)
for (i = 0; i < num_elem; i++)
{
- varref ref;
- basic_block phiargbb, block;
- edge e;
-
- ref = (varref) VARRAY_GENERIC_PTR (phi_vec, i);
- phiargbb = VARRAY_BB (VARDEF_PHI_CHAIN_BB (phi_node), i);
- block = VARREF_BB (phi_node);
+ phi_arg arg;
- e = find_edge (phiargbb, block);
+ arg = get_phi_arg (phi_node, i);
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "\n Examining argument #%d: ", i);
- dump_varref (dump_file, "", ref, 0, 0);
+ dump_varref (dump_file, "", arg->def, 0, 0);
fprintf (dump_file, " incoming via basic block %d\n",
- phiargbb->index);
+ arg->e->src->index);
fprintf (dump_file, " Edge (%d -> %d) is %sexecutable\n",
- phiargbb->index, block->index,
- (e->flags & EDGE_EXECUTABLE)
+ arg->e->src->index, arg->e->dest->index,
+ (arg->e->flags & EDGE_EXECUTABLE)
? ""
: "not ");
}
/* Compute the meet operator for the current PHI argument. */
- if (e->flags & EDGE_EXECUTABLE)
+ if (arg->e->flags & EDGE_EXECUTABLE)
{
latticevalue current_parm_lattice_val;
- unsigned int current_parm = VARREF_ID (ref);
+ unsigned int current_parm = VARREF_ID (arg->def);
current_parm_lattice_val = values[current_parm].lattice_val;
@@ -793,7 +782,7 @@ evaluate_expr (expr)
/* The lattice value of a USE reference is the value of its
immediately reaching definition. */
- rdef = VARUSE_CHAIN (r);
+ rdef = VARUSE_IMM_RDEF (r);
id = VARREF_ID (rdef);
if (values[id].lattice_val == VARYING)
@@ -973,7 +962,7 @@ initialize ()
executable_blocks = sbitmap_alloc (last_basic_block);
sbitmap_zero (executable_blocks);
- for (i = 0; i < NUM_EDGES (edges); i++)
+ for (i = 0; i < (unsigned)(NUM_EDGES (edges)); i++)
edges->index_to_edge[i]->flags &= ~EDGE_EXECUTABLE;
VARRAY_GENERIC_PTR_INIT (edge_info, NUM_EDGES (edges) / 2, "edge_info");
Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v
retrieving revision 1.1.4.11
diff -d -u -p -r1.1.4.11 tree-ssa-pre.c
--- tree-ssa-pre.c 16 Aug 2002 15:50:33 -0000 1.1.4.11
+++ tree-ssa-pre.c 26 Aug 2002 23:20:29 -0000
@@ -257,15 +257,13 @@ set_var_phis (phi, i)
if (!TEST_BIT (varphis[i], VARREF_BB (phi)->index))
{
varref phi_operand;
- varray_type phi_chain;
size_t curr_phi_operand;
SET_BIT (varphis[i], VARREF_BB (phi)->index);
- phi_chain = VARDEF_PHI_CHAIN (phi);
for (curr_phi_operand = 0;
- curr_phi_operand < VARRAY_ACTIVE_SIZE (phi_chain);
+ curr_phi_operand < get_num_phi_args (phi);
curr_phi_operand++)
{
- phi_operand = VARRAY_GENERIC_PTR (phi_chain, curr_phi_operand);
+ phi_operand = get_phi_arg (phi, curr_phi_operand)->def;
if (VARREF_TYPE (phi_operand) == VARPHI)
set_var_phis (phi_operand, i);
}
@@ -325,7 +323,7 @@ find_varref_for_var (ei, real, var)
continue;
if (VARREF_SYM (ref) != var)
continue;
- if (!VARUSE_CHAIN (ref))
+ if (!VARUSE_IMM_RDEF (ref))
continue;
return ref;
}
@@ -358,9 +356,9 @@ defs_y_dom_x ( y, x)
continue;
if (VARREF_SYM (ref) != TREE_OPERAND (EXPRREF_EXPR (y), i))
continue;
- if (!VARUSE_CHAIN (ref))
+ if (!VARUSE_IMM_RDEF (ref))
return false;
- if (!(a_dom_b (VARREF_BB (VARUSE_CHAIN (ref)), EXPRREF_BB (x))))
+ if (!(a_dom_b (VARREF_BB (VARUSE_IMM_RDEF (ref)), EXPRREF_BB (x))))
return false;
break;
}
@@ -386,7 +384,7 @@ defs_match_p (ei, t1, t2)
(TREE_CODE (VARREF_EXPR (use1)) != TREE_CODE (t2)))
continue;
use2 = find_varref_for_var (ei, t2, VARREF_SYM (use1));
- if (!use2 || (VARUSE_CHAIN (use2) != VARUSE_CHAIN (use1)))
+ if (!use2 || (VARUSE_IMM_RDEF (use2) != VARUSE_IMM_RDEF (use1)))
return false;
}
return true;
@@ -544,10 +542,9 @@ opnum_of_phi (phi, j)
when it sees a phi in the successor during it's traversal. So the
order is dependent on the traversal order, which i don't feel like
duplicating. Thus the existence of VARDEF_PHI_CHAIN_BB. */
- for (i = 0 ; i < VARRAY_ACTIVE_SIZE (VARDEF_PHI_CHAIN_BB (phi)); i++)
+ for (i = 0 ; i < get_num_phi_args (phi); i++)
{
- basic_block bb = VARRAY_BB (VARDEF_PHI_CHAIN_BB (phi), i);
- if (bb->index == j)
+ if (get_phi_arg (phi, i)->e->src->index == j)
return i;
}
@@ -578,14 +575,14 @@ phi_opnd_from_res (Z, j, b)
{
/* If v is defined by phi in b */
if (VARREF_TYPE (v) == VARUSE
- && VARREF_TYPE (VARUSE_CHAIN (v)) == VARPHI)
+ && VARREF_TYPE (VARUSE_IMM_RDEF (v)) == VARPHI)
{
- varref phi = VARUSE_CHAIN (v);
+ varref phi = VARUSE_IMM_RDEF (v);
if (VARREF_BB (phi) == b)
{
/* replace v in Q by j'th operand of v's phi */
int opnum = opnum_of_phi (phi, j);
- varref op = VARRAY_GENERIC_PTR (VARDEF_PHI_CHAIN (phi), opnum);
+ varref op = get_phi_arg (phi, opnum)->def;
VARRAY_GENERIC_PTR (Q, i) = op;
}
@@ -684,11 +681,11 @@ rename_2 (ei, rename2_set)
if (VARREF_TYPE (op1) != VARUSE)
continue;
if (VARREF_TYPE (op1) == VARUSE)
- op1 = VARUSE_CHAIN (op1);
+ op1 = VARUSE_IMM_RDEF (op1);
op2 = VARRAY_GENERIC_PTR (Y, k);
if (op2 && VARREF_TYPE (op2) == VARUSE)
- op2 = VARUSE_CHAIN (op2);
+ op2 = VARUSE_IMM_RDEF (op2);
if (op1 != op2)
{
@@ -720,7 +717,7 @@ rename_2 (ei, rename2_set)
if (!ref)
continue;
if (VARREF_TYPE (ref) == VARUSE)
- ref = VARUSE_CHAIN (ref);
+ ref = VARUSE_IMM_RDEF (ref);
if (!a_dom_b (VARREF_BB (ref), EXPRREF_BB (X)))
{
@@ -1312,9 +1309,10 @@ expr_phi_insertion (dfs, ei)
&& (TREE_OPERAND (real, 1) == NULL
|| VARREF_SYM (ref) != TREE_OPERAND (real, 1)))
continue;
- if (!VARUSE_CHAIN (ref) || VARREF_TYPE (VARUSE_CHAIN (ref)) != VARPHI)
+ if (!VARUSE_IMM_RDEF (ref)
+ || VARREF_TYPE (VARUSE_IMM_RDEF (ref)) != VARPHI)
continue;
- set_var_phis (VARUSE_CHAIN (ref), varcount++);
+ set_var_phis (VARUSE_IMM_RDEF (ref), varcount++);
}
}
}
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.11
diff -d -u -p -r1.1.4.11 tree-ssa.c
--- tree-ssa.c 23 Aug 2002 16:52:58 -0000 1.1.4.11
+++ tree-ssa.c 26 Aug 2002 23:20:29 -0000
@@ -25,6 +25,7 @@ Boston, MA 02111-1307, USA. */
#include "flags.h"
#include "rtl.h"
#include "tm_p.h"
+#include "ggc.h"
#include "hard-reg-set.h"
#include "basic-block.h"
#include "output.h"
@@ -272,12 +273,12 @@ search_fud_chains (bb, idom)
/* Set up a def-use chain between CURRDEF (the immediately
reaching definition for REF) and REF. Each definition may
have more than one immediate use. */
- if (currdef && VARUSE_CHAIN (ref) != currdef)
+ if (currdef && VARUSE_IMM_RDEF (ref) != currdef)
add_ref_to_list_end (VARDEF_IMM_USES (currdef), ref);
/* Set up a use-def chain between REF and CURRDEF. */
- VARUSE_CHAIN (ref) = currdef;
+ VARUSE_IMM_RDEF (ref) = currdef;
}
else if (VARREF_TYPE (ref) == VARDEF || VARREF_TYPE (ref) == VARPHI)
{
@@ -318,12 +319,10 @@ search_fud_chains (bb, idom)
currdef = TREE_CURRDEF (sym);
/* Besides storing the incoming definition CURRDEF, we also store
- BB, which is the basic block that we are receiving
- CURRDEF from. */
+ E, which is the edge that we are receiving CURRDEF from. */
if (currdef)
{
- VARRAY_PUSH_GENERIC_PTR (VARDEF_PHI_CHAIN (phi), currdef);
- VARRAY_PUSH_BB (VARDEF_PHI_CHAIN_BB (phi), bb);
+ add_phi_arg (phi, currdef, e);
/* Set a def-use edge between CURRDEF and this PHI node. */
add_ref_to_list_end (VARDEF_IMM_USES (currdef), phi);
@@ -423,7 +422,7 @@ tree_compute_rdefs ()
FOR_EACH_REF (u, tmp, TREE_REFS (sym))
{
if (VARREF_TYPE (u) == VARUSE)
- follow_chain (VARUSE_CHAIN (u), u);
+ follow_chain (VARUSE_IMM_RDEF (u), u);
}
}
@@ -569,10 +568,9 @@ follow_chain (d, u)
if (VARREF_TYPE (d) == VARPHI)
{
size_t i;
- varray_type phi_chain = VARDEF_PHI_CHAIN (d);
- for (i = 0; i < VARRAY_ACTIVE_SIZE (phi_chain); i++)
- follow_chain (VARRAY_GENERIC_PTR (phi_chain, i), u);
+ for (i = 0; i < get_num_phi_args (d); i++)
+ follow_chain (get_phi_arg (d, i)->def, u);
}
}
@@ -630,27 +628,26 @@ tree_ssa_remove_phi_alternative (phi_nod
varref phi_node;
basic_block block;
{
- varray_type phi_vec = VARDEF_PHI_CHAIN (phi_node);
+ varray_type phi_vec = VARDEF_PHI_ARGS (phi_node);
unsigned int num_elem = VARRAY_ACTIVE_SIZE (phi_vec);
unsigned int i;
for (i = 0; i < num_elem; i++)
{
varref ref;
+ basic_block src_bb;
+ phi_arg arg;
- ref = (varref)VARRAY_GENERIC_PTR (phi_vec, i);
+ arg = get_phi_arg (phi_node, i);
+ ref = arg->def;
+ src_bb = arg->e->src;
- if (VARRAY_BB (VARDEF_PHI_CHAIN_BB (phi_node), i) == block)
+ if (src_bb == block)
{
/* If we are not at the last element, switch the last element
with the element we want to delete. */
if (i != num_elem - 1)
- {
- VARRAY_GENERIC_PTR (phi_vec, i)
- = VARRAY_GENERIC_PTR (phi_vec, num_elem - 1);
- VARRAY_BB (VARDEF_PHI_CHAIN_BB (phi_node), i)
- = VARRAY_BB (VARDEF_PHI_CHAIN_BB (phi_node), num_elem - 1);
- }
+ set_phi_arg (phi_node, i, get_phi_arg (phi_node, num_elem - 1));
/* Shrink the vector. */
VARRAY_ACTIVE_SIZE (phi_vec) -= 1;
@@ -658,3 +655,19 @@ tree_ssa_remove_phi_alternative (phi_nod
}
}
+
+/* Add a new argument to PHI for definition DEF reaching in via edge E. */
+
+void
+add_phi_arg (phi, def, e)
+ varref phi;
+ varref def;
+ edge e;
+{
+ phi_arg arg;
+
+ arg = (phi_arg) ggc_alloc (sizeof (*arg));
+ arg->def = def;
+ arg->e = e;
+ VARRAY_PUSH_GENERIC_PTR (VARDEF_PHI_ARGS (phi), arg);
+}