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]: PRE Update (Diego, need your approval for part)


I've put the small change that needs your approval first,so it's easy to find.
It makes create_tmp_var work again.

It also adds a create_tmp_var_noc that the language specific
gimplification functions should use. noc = no context. Hard to come up
with a name that wasn't too long. The gimplify context doesn't need to be
pushed or popped, since something already took care of it. If you do
push it, we'll abort, and i didn't want to directly expose
create_tmp_var_1.


2002-10-17 Daniel Berlin <dberlin@dberlin.org>

* gimplify.c (create_tmp_var): New function, wraps calls to
create_tmp_var_1 with pushing/popping of right context.
All internal gimplify.c now use create_tmp_var_1.
(create_tmp_var_noc): New function, create the var without
pushing/popping, and without exposing internals of create_tmp_var_1.
Only one use of this.

* tree-simple.h (create_tmp_var_noc): New prototype.

* c-simplify.c (simplify_stmt_expr): create_tmp_var changed to
create_tmp_var_noc.

* tree-ssa-pre.c: Add WAITING_FOR_DFA_UPDATE around code waiting for DFA
functions to keep refs up to date.
(add_call_to_ei): occurs and occurstmts is now an
array of tree pointers, not trees. Update approriately.
(insert_occ_in_preorder_dt_order_1): Ditto.
(tree_perform_ssapre): Ditto.
(find_use_for_var): Removed function.
(orig_expr_map): Removed global, removed uses.
(struct ei): Added injfixups member.
(is_strred_cand): STRIP_WFL the expression.
(calculate_increment): Ditto.
(is_injuring_def): Ditto.
(defs_y_dom_x): Ditto. Also account for fact that y is now a full
expression, not just an RHS.
(defs_match_p): Ditto (t2 is no longer just an RHS).
(finalize_1): Do insertion by replacement.
(repair_injury): Clean up, do insertion by replacement.
(find_reaching_def_of_var): Do backwards search in a cleaner way.
(update_ssa_for_new_use): Change how we do replacement.
(code_motion): Insertion by replacement. Print EXPR_WFL_LINENO, not
STMT_LINENO.
(pre_part_1_trav): Just create_tmp_var will now suffice.
Index: c-simplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/c-simplify.c,v
retrieving revision 1.1.4.30
diff -c -3 -p -w -B -b -r1.1.4.30 c-simplify.c
*** c-simplify.c 18 Oct 2002 03:36:38 -0000 1.1.4.30
--- c-simplify.c 18 Oct 2002 19:24:30 -0000
*************** simplify_stmt_expr (expr_p, pre_p)
*** 797,803 ****
abort ();
#endif

! temp = create_tmp_var (TREE_TYPE (last_expr), "retval");
mod = build (INIT_EXPR, TREE_TYPE (temp), temp, last_expr);
EXPR_STMT_EXPR (last_expr_stmt) = mod;
}
--- 797,803 ----
abort ();
#endif

! temp = create_tmp_var_noc (TREE_TYPE (last_expr), "retval");
mod = build (INIT_EXPR, TREE_TYPE (temp), temp, last_expr);
EXPR_STMT_EXPR (last_expr_stmt) = mod;
}
Index: tree-simple.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-simple.h,v
retrieving revision 1.1.4.15
diff -c -3 -p -w -B -b -r1.1.4.15 tree-simple.h
*** tree-simple.h 14 Oct 2002 17:01:53 -0000 1.1.4.15
--- tree-simple.h 18 Oct 2002 19:24:30 -0000
*************** Boston, MA 02111-1307, USA. */
*** 26,31 ****
--- 26,32 ----
extern void insert_before_continue_end PARAMS ((tree, tree));
extern void tree_build_scope PARAMS ((tree *));
extern tree create_tmp_var PARAMS ((tree, const char *));
+ extern tree create_tmp_var_noc PARAMS ((tree, const char *));
extern tree create_tmp_alias_var PARAMS ((tree, const char *));
extern bool is_simple_tmp_var PARAMS ((tree));
extern tree get_initialized_tmp_var PARAMS ((tree, tree *));
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.3
diff -c -3 -p -w -B -b -r1.1.2.3 gimplify.c
*** gimplify.c 18 Oct 2002 03:36:39 -0000 1.1.2.3
--- gimplify.c 18 Oct 2002 19:24:30 -0000
*************** static tree add_stmt_to_compound PARAMS
*** 55,60 ****
--- 55,61 ----
static void simplify_asm_expr PARAMS ((tree, tree *));
static void simplify_bind_expr PARAMS ((tree *, tree *));
static inline void remove_suffix PARAMS ((char *, int));
+ static tree create_tmp_var_1 PARAMS ((tree, const char *));
static void push_gimplify_context PARAMS ((void));
static void pop_gimplify_context PARAMS ((void));
static void wrap_with_wfl PARAMS ((tree *));
*************** simplify_bind_expr (expr_p, pre_p)
*** 542,548 ****
}
else
{
! temp = create_tmp_var (TREE_TYPE (bind_expr), "retval");
if (*p != empty_stmt_node)
*p = build (INIT_EXPR, TREE_TYPE (temp), temp, *p);
}
--- 544,550 ----
}
else
{
! temp = create_tmp_var_1 (TREE_TYPE (bind_expr), "retval");
if (*p != empty_stmt_node)
*p = build (INIT_EXPR, TREE_TYPE (temp), temp, *p);
}
*************** simplify_cond_expr (expr_p, pre_p)
*** 949,955 ****
the arms. */
if (! VOID_TYPE_P (TREE_TYPE (expr)))
{
! tmp = create_tmp_var (TREE_TYPE (expr), "iftmp");

/* Build the then clause, 't1 = a;'. */
TREE_OPERAND (expr, 1)
--- 951,957 ----
the arms. */
if (! VOID_TYPE_P (TREE_TYPE (expr)))
{
! tmp = create_tmp_var_1 (TREE_TYPE (expr), "iftmp");

/* Build the then clause, 't1 = a;'. */
TREE_OPERAND (expr, 1)
*************** add_tree (t, list_p)
*** 1363,1374 ****
--- 1365,1405 ----

/* Create a new temporary variable declaration of type TYPE. Returns the
newly created decl and pushes it into the current binding. */
+ tree
+ create_tmp_var_noc (type, prefix)
+ tree type;
+ const char *prefix;
+ {
+ return create_tmp_var_1 (type, prefix);
+ }

+ /* Create a new temporary variable declaration of type TYPE. Returns the
+ newly created decl and pushes it into the top-level binding. */
tree
create_tmp_var (type, prefix)
tree type;
const char *prefix;
{
+ tree temp;
+ tree fnbody;
+
+ push_gimplify_context ();
+ temp = create_tmp_var_1 (type, prefix);
+ fnbody = DECL_SAVED_TREE (current_function_decl);
+ STRIP_WFL (fnbody);
+ declare_tmp_vars (gimplify_ctxp->temps, fnbody);
+ pop_gimplify_context ();
+ return temp;
+ }
+
+ /* Create a new temporary variable declaration of type TYPE. Returns the
+ newly created decl and pushes it into the current binding. */
+
+ static tree
+ create_tmp_var_1 (type, prefix)
+ tree type;
+ const char *prefix;
+ {
static unsigned int id_num = 1;
char *tmp_name;
char *preftmp = NULL;
*************** get_initialized_tmp_var (val, pre_p)
*** 1497,1503 ****

prefix = get_name (val);
simplify_expr (&val, pre_p, NULL, is_simple_rhs, fb_rvalue);
! t = create_tmp_var (TREE_TYPE (val), prefix);
mod = build (INIT_EXPR, TREE_TYPE (t), t, val);
add_tree (mod, pre_p);

--- 1528,1534 ----

prefix = get_name (val);
simplify_expr (&val, pre_p, NULL, is_simple_rhs, fb_rvalue);
! t = create_tmp_var_1 (TREE_TYPE (val), prefix);
mod = build (INIT_EXPR, TREE_TYPE (t), t, val);
add_tree (mod, pre_p);

Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v
retrieving revision 1.1.4.25
diff -c -3 -p -w -B -b -r1.1.4.25 tree-ssa-pre.c
*** tree-ssa-pre.c 18 Oct 2002 03:36:39 -0000 1.1.4.25
--- tree-ssa-pre.c 18 Oct 2002 19:10:23 -0000
*************** static inline bool a_dom_b PARAMS ((basi
*** 89,95 ****
static void set_var_phis PARAMS ((struct expr_info *, tree_ref, int));
static inline tree_ref find_rhs_use_for_var PARAMS ((tree_ref, tree));
static inline tree_ref maybe_find_rhs_use_for_var PARAMS ((tree_ref, tree));
- static inline tree_ref find_use_for_var PARAMS ((tree, tree));
static inline tree_ref find_def_for_stmt PARAMS ((tree));
static void expr_phi_insertion PARAMS ((sbitmap *, struct expr_info *));
static int pre_part_1_trav PARAMS ((struct expr_info *, void *));
--- 89,94 ----
*************** static bool can_insert PARAMS ((tree_ref
*** 106,117 ****
static inline bool defs_match_p PARAMS ((struct expr_info *, tree, tree));
static inline bool defs_y_dom_x PARAMS ((struct expr_info *, tree_ref, tree_ref));
static void assign_new_class PARAMS ((tree_ref, varray_type *));
! static void insert_occ_in_preorder_dt_order_1 PARAMS ((struct expr_info *, fibheap_t, basic_block));
! static void insert_occ_in_preorder_dt_order PARAMS ((struct expr_info *, fibheap_t));
! static void insert_euse_in_preorder_dt_order_1 PARAMS ((struct expr_info *, fibheap_t, basic_block));
! static void insert_euse_in_preorder_dt_order PARAMS ((struct expr_info *, fibheap_t));
static inline int opnum_of_phi PARAMS ((tree_ref, int));
! static varray_type phi_opnd_from_res PARAMS ((struct expr_info *, tree_ref, int, basic_block));
static splay_tree rename_2 PARAMS ((struct expr_info *, varray_type *));
static void rename_1 PARAMS ((struct expr_info *));
static void finalize_2 PARAMS ((struct expr_info *));
--- 105,121 ----
static inline bool defs_match_p PARAMS ((struct expr_info *, tree, tree));
static inline bool defs_y_dom_x PARAMS ((struct expr_info *, tree_ref, tree_ref));
static void assign_new_class PARAMS ((tree_ref, varray_type *));
! static void insert_occ_in_preorder_dt_order_1 PARAMS ((struct expr_info *,
! fibheap_t, basic_block));
! static void insert_occ_in_preorder_dt_order PARAMS ((struct expr_info *,
! fibheap_t));
! static void insert_euse_in_preorder_dt_order_1 PARAMS ((struct expr_info *,
! fibheap_t, basic_block));
! static void insert_euse_in_preorder_dt_order PARAMS ((struct expr_info *,
! fibheap_t));
static inline int opnum_of_phi PARAMS ((tree_ref, int));
! static varray_type phi_opnd_from_res PARAMS ((struct expr_info *, tree_ref,
! int, basic_block));
static splay_tree rename_2 PARAMS ((struct expr_info *, varray_type *));
static void rename_1 PARAMS ((struct expr_info *));
static void finalize_2 PARAMS ((struct expr_info *));
*************** static int class_count;
*** 143,149 ****
static int preorder_count;
/*FIXME: Move into expr_info or make them go away. */
static tree_ref *avdefs;
! static splay_tree orig_expr_map;
static splay_tree new_stmt_map;

static splay_tree need_repair_map;
--- 147,153 ----
static int preorder_count;
/*FIXME: Move into expr_info or make them go away. */
static tree_ref *avdefs;
!
static splay_tree new_stmt_map;

static splay_tree need_repair_map;
*************** struct expr_info
*** 174,179 ****
--- 178,186 ----
bool strred_cand;
/* Map of repairs we've already completed. */
htab_t repaired;
+ /* List of injury defs we need to fix reaching defs on *after* other
+ insertions. */
+ ref_list injfixups;
};

/* Returns true if a dominates b */
*************** is_strred_cand (expr)
*** 255,260 ****
--- 262,268 ----
tree_ref ref, def, use;
struct ref_list_node *tmp;

+ STRIP_WFL (expr);
/* Multiplications that def a variable they use can't be strength reduced.
Removing the multiplications would require adding more multiplications.
IE a = a * 5. */
*************** is_injuring_def (ei, inj)
*** 290,295 ****
--- 298,304 ----
{
if (!inj || !is_simple_modify_expr (inj))
return false;
+ STRIP_WFL (inj);
if (TREE_CODE (TREE_OPERAND (inj, 1)) != PLUS_EXPR
&& TREE_CODE (TREE_OPERAND (inj, 1)) != MINUS_EXPR)
return false;
*************** set_var_phis (ei, phi, i)
*** 411,417 ****
break;
}

! phi_operand = find_rhs_use_for_var (ird, ref_var (phi_operand));
phi_operand = imm_reaching_def (phi_operand);
}
if (ref_type (phi_operand) & V_PHI)
--- 423,430 ----
break;
}

! phi_operand = find_rhs_use_for_var (ird,
! ref_var (phi_operand));
phi_operand = imm_reaching_def (phi_operand);
}
if (ref_type (phi_operand) & V_PHI)
*************** maybe_find_rhs_use_for_var (def, var)
*** 478,509 ****
return NULL;
}

- /* Given the the real occurrence and a variable,
- find the V_USE of the variable contained in that occurrence. */
- static inline tree_ref
- find_use_for_var (real, var)
- tree real;
- tree var;
- {
- struct ref_list_node *tmp;
- tree_ref ref;
- splay_tree_node orignode;
- tree orig = real;
-
- orignode = splay_tree_lookup (orig_expr_map, (splay_tree_key) orig);
- real = (tree) orignode->value;

- /* Now look for the use of var in that expression. */
- FOR_EACH_REF (ref, tmp, tree_refs (real))
- {
- if (!(ref_type (ref) & V_USE)
- || ref_var (ref) != var
- || !imm_reaching_def (ref))
- continue;
- return ref;
- }
- return NULL;
- }
/* Determine if the definitions of variables in Y dominate the basic
block of X. */
static inline bool
--- 491,497 ----
*************** defs_y_dom_x (ei, y, x)
*** 522,537 ****
{
tree_ref ref;
struct ref_list_node *tmp;
! if (!TREE_OPERAND (ref_expr (y), i))
continue;
FOR_EACH_REF (ref, tmp, tree_refs (ref_stmt (y)))
{
/* Find the ref for this operand. */
! if (!(ref_type (ref) & V_USE)
! || !is_simple_modify_expr (ref_expr (ref))
! || TREE_OPERAND (ref_expr (ref), 1) != ref_expr (y))
continue;
! if (ref_var (ref) != TREE_OPERAND (ref_expr (y), i))
continue;
if (!imm_reaching_def (ref))
return false;
--- 508,532 ----
{
tree_ref ref;
struct ref_list_node *tmp;
! tree yexpr, refexpr;
!
! yexpr = ref_expr (y);
! STRIP_WFL (yexpr);
! yexpr = TREE_OPERAND (yexpr, 1);
!
! if (!TREE_OPERAND (yexpr, i))
continue;
FOR_EACH_REF (ref, tmp, tree_refs (ref_stmt (y)))
{
/* Find the ref for this operand. */
! if (!(ref_type (ref) & V_USE))
continue;
! refexpr = ref_expr (ref);
! STRIP_WFL (refexpr);
! if (!is_simple_modify_expr (refexpr)
! || TREE_OPERAND (refexpr, 1) != yexpr)
! continue;
! if (ref_var (ref) != TREE_OPERAND (yexpr, i))
continue;
if (!imm_reaching_def (ref))
return false;
*************** defs_y_dom_x (ei, y, x)
*** 539,550 ****
while (is_injuring_def (ei, ref_expr (imm_reaching_def (ref))))
{
ref = find_rhs_use_for_var (imm_reaching_def (ref),
! TREE_OPERAND (ref_expr (y), i));
if (ref_type (imm_reaching_def (ref)) & V_PHI
|| ref_type (imm_reaching_def (ref)) & M_DEFAULT)
break;
ref = find_rhs_use_for_var (imm_reaching_def (ref),
! TREE_OPERAND (ref_expr (y), i));
}
if (!(a_dom_b (ref_bb (imm_reaching_def (ref)), ref_bb (x))))
return false;
--- 535,546 ----
while (is_injuring_def (ei, ref_expr (imm_reaching_def (ref))))
{
ref = find_rhs_use_for_var (imm_reaching_def (ref),
! TREE_OPERAND (yexpr, i));
if (ref_type (imm_reaching_def (ref)) & V_PHI
|| ref_type (imm_reaching_def (ref)) & M_DEFAULT)
break;
ref = find_rhs_use_for_var (imm_reaching_def (ref),
! TREE_OPERAND (yexpr, i));
}
if (!(a_dom_b (ref_bb (imm_reaching_def (ref)), ref_bb (x))))
return false;
*************** defs_match_p (ei, t1, t2)
*** 566,573 ****
--- 562,575 ----
{
tree_ref use1;
tree_ref use2;
+ tree origt2;
struct ref_list_node *tmp;

+ STRIP_WFL (t1);
+ STRIP_WFL (t2);
+ origt2 = t2;
+ t2 = TREE_OPERAND (t2, 1);
+
FOR_EACH_REF (use1, tmp, tree_refs (t1))
{
tree use1expr = ref_expr (use1);
*************** defs_match_p (ei, t1, t2)
*** 574,583 ****
if (!(ref_type (use1) & V_USE)
|| !is_simple_modify_expr (use1expr))
continue;
use1expr = TREE_OPERAND (use1expr, 1);
if (TREE_CODE (use1expr) != TREE_CODE (t2))
continue;
! use2 = find_use_for_var (t2, ref_var (use1));
if (!use2)
return false;
/* Find the injuring definition, if one exists. */
--- 577,588 ----
if (!(ref_type (use1) & V_USE)
|| !is_simple_modify_expr (use1expr))
continue;
+
+ STRIP_WFL (use1expr);
use1expr = TREE_OPERAND (use1expr, 1);
if (TREE_CODE (use1expr) != TREE_CODE (t2))
continue;
! use2 = find_rhs_use_for_var (find_def_for_stmt (origt2), ref_var (use1));
if (!use2)
return false;
/* Find the injuring definition, if one exists. */
*************** insert_occ_in_preorder_dt_order_1 (ei, f
*** 662,690 ****
for (i = 0; i < VARRAY_ACTIVE_SIZE (ei->occurs); i++)
{
tree_ref newref;
! tree occurstmt = VARRAY_TREE (ei->occurstmts, i);
tree_ref occurref = VARRAY_GENERIC_PTR (ei->refs, i);
if (ref_bb (occurref) != block)
continue;
! if (TREE_CODE (VARRAY_TREE (ei->occurs, i)) == CALL_EXPR)
{
! /* FIXME: Hack. Passing the address of local trees to create_ref
! is not correct. We should keep statement and
! expression pointers here. */
! newref = create_ref (VARRAY_TREE (ei->occurs, i),
E_KILL, block, occurstmt,
! VARRAY_TREE (ei->occurs, i), NULL, true);
VARRAY_PUSH_GENERIC_PTR (ei->erefs, newref);
fibheap_insert (fh, preorder_count++, newref);
}
else
{
! /* FIXME: Hack. Passing the address of local trees to create_ref
! is not correct. We should keep statement and
! expression pointers here. */
! newref = create_ref (VARRAY_TREE (ei->occurs, i),
E_USE, block, occurstmt,
! VARRAY_TREE (ei->occurs, i), NULL, true);
VARRAY_PUSH_GENERIC_PTR (ei->erefs, newref);
set_expruse_def (newref, NULL);
set_exprref_class (newref, 0);
--- 666,689 ----
for (i = 0; i < VARRAY_ACTIVE_SIZE (ei->occurs); i++)
{
tree_ref newref;
! tree *occurexpr = VARRAY_GENERIC_PTR (ei->occurs, i);
! tree *occurstmt = VARRAY_GENERIC_PTR (ei->occurstmts, i);
tree_ref occurref = VARRAY_GENERIC_PTR (ei->refs, i);
if (ref_bb (occurref) != block)
continue;
! if (TREE_CODE (*occurexpr) == CALL_EXPR)
{
! newref = create_ref (*occurexpr,
E_KILL, block, occurstmt,
! occurexpr, NULL, true);
VARRAY_PUSH_GENERIC_PTR (ei->erefs, newref);
fibheap_insert (fh, preorder_count++, newref);
}
else
{
! newref = create_ref (*occurexpr,
E_USE, block, occurstmt,
! occurexpr, NULL, true);
VARRAY_PUSH_GENERIC_PTR (ei->erefs, newref);
set_expruse_def (newref, NULL);
set_exprref_class (newref, 0);
*************** rename_2 (ei, rename2_set)
*** 889,894 ****
--- 888,894 ----
bool match = true;
tree_ref op1;
struct ref_list_node *tmp2;
+
/* if (all corresponding variables in Y and X have
the same SSA version) */
k = 0;
*************** finalize_1 (ei, temp)
*** 1470,1475 ****
--- 1474,1480 ----
{
tree stmt;
tree expr;
+ tree *place;
basic_block bb;
tree endtree;
struct ref_list_node *tmp;
*************** finalize_1 (ei, temp)
*** 1492,1504 ****
}
expr = fold (build_modify_expr (temp, NOP_EXPR,
deep_copy_node (ei->expr)));
- stmt = build_stmt (EXPR_STMT, expr);
- TREE_TYPE (stmt) = TREE_TYPE (expr);
bb = ref_bb (X);
/* If it's a goto, we need to insert *before* it.
This might not be necessary once goto elimination
is functional. */
! endtree = last_stmt (bb);
/* Update the SSA for the newly inserted definition.
This is a phi operand occurrence insertion, so we know
*something* caused one or more variables in our expression
--- 1497,1526 ----
}
expr = fold (build_modify_expr (temp, NOP_EXPR,
deep_copy_node (ei->expr)));
bb = ref_bb (X);
+ endtree = last_stmt (bb);
+ /* FIXME: Need DFA inserting updating to do this the right
+ way. */
/* If it's a goto, we need to insert *before* it.
This might not be necessary once goto elimination
is functional. */
! if (is_ctrl_altering_stmt (endtree))
! {
! stmt = build (COMPOUND_EXPR, void_type_node, expr, endtree);
! place = &TREE_OPERAND (stmt, 0);
! }
! else
! {
! stmt = build (COMPOUND_EXPR, void_type_node, endtree, expr);
! place = &TREE_OPERAND (stmt, 1);
! }
!
! *bb->end_tree_p = stmt;
! TREE_CHAIN (stmt) = TREE_CHAIN (endtree);
! TREE_CHAIN (endtree) = NULL;
! TREE_TYPE (stmt) = TREE_TYPE (expr);
!
! #if WAITING_FOR_DFA_UPDATE
/* Update the SSA for the newly inserted definition.
This is a phi operand occurrence insertion, so we know
*something* caused one or more variables in our expression
*************** finalize_1 (ei, temp)
*** 1526,1544 ****
(splay_tree_key) expr,
(splay_tree_value) stmt);

! #if 0
! if (is_ctrl_altering_stmt (endtree))
! insert_stmt_tree_before (stmt, endtree, bb);
! else
! insert_stmt_tree_after (stmt, endtree, bb);
#endif

/* FIXME: Hack. Passing the address of local trees to
create_ref is not correct. We should keep statement and
expression pointers here. */
set_expruse_def (X,create_ref (expr, E_USE,
! ref_bb (X), stmt, expr,
! &TREE_OPERAND (stmt, 0), true));
VARRAY_PUSH_GENERIC_PTR (ei->erefs, expruse_def (X));
set_exprref_reload (expruse_def (X), false);
set_exprref_save (expruse_def (X), true);
--- 1548,1566 ----
(splay_tree_key) expr,
(splay_tree_value) stmt);

!
!
#endif
+ /*
+ expruse_def (X) = new occurrence.
+ */

/* FIXME: Hack. Passing the address of local trees to
create_ref is not correct. We should keep statement and
expression pointers here. */
set_expruse_def (X,create_ref (expr, E_USE,
! ref_bb (X), bb->end_tree_p,
! place, place, true));
VARRAY_PUSH_GENERIC_PTR (ei->erefs, expruse_def (X));
set_exprref_reload (expruse_def (X), false);
set_exprref_save (expruse_def (X), true);
*************** finalize_1 (ei, temp)
*** 1547,1555 ****
set_expruse_has_real_use (expruse_def (X), true);
set_exprref_save (X, false);
set_exprref_reload (X, false);
- /*
- expruse_def (X) = new occurrence.
- */
}
else
{
--- 1569,1574 ----
*************** down_safety (ei)
*** 1678,1683 ****
--- 1697,1704 ----
}
}

+ /* Determine whether the given PHI will require us to insert on a critical
+ edge. */
#if 0
static bool
requires_edge_placement (phi)
*************** static bool
*** 1858,1868 ****
can_insert (op)
tree_ref op;
{
-
tree_ref def;
if (expruse_def (op) == NULL)
return true;
def = expruse_def (op);
if (!expruse_has_real_use (op))
if (ref_type (def) & E_PHI && !(exprphi_willbeavail (def)))
return true;
--- 1880,1892 ----
can_insert (op)
tree_ref op;
{
tree_ref def;
+
if (expruse_def (op) == NULL)
return true;
+
def = expruse_def (op);
+
if (!expruse_has_real_use (op))
if (ref_type (def) & E_PHI && !(exprphi_willbeavail (def)))
return true;
*************** calculate_increment (ei, expr)
*** 1907,1912 ****
--- 1932,1938 ----
tree expr;
{
tree incr;
+ STRIP_WFL (expr);

/*XXX: Currently assume it's like a = a + 5, thus, this will give us the 5.
*/
*************** calculate_increment (ei, expr)
*** 1926,1933 ****
}
#endif
return incr;
-
}
/* Repair the injury for USE. Currently ugly as hell, i'm just making it do
*something* so i can make sure we are choosing candidates and renaming
properly. It's uncommented so that you don't accidently try to understand it
--- 1952,1959 ----
}
#endif
return incr;
}
+
/* Repair the injury for USE. Currently ugly as hell, i'm just making it do
*something* so i can make sure we are choosing candidates and renaming
properly. It's uncommented so that you don't accidently try to understand it
*************** repair_injury (ei, use, temp, orig_euse)
*** 1944,1950 ****
tree expr, stmt;
basic_block bb;
struct ref_list_node *tmp;
! tree_ref tempref;

for (i = 0; i < 2; i++)
{
--- 1970,1976 ----
tree expr, stmt;
basic_block bb;
struct ref_list_node *tmp;
! ref_list toprocess = create_ref_list();

for (i = 0; i < 2; i++)
{
*************** repair_injury (ei, use, temp, orig_euse)
*** 1953,1959 ****
if (!DECL_P (TREE_OPERAND (ei->expr, i)))
continue;
if (ref_type (use) & E_USE)
! v = find_use_for_var (ref_expr (use), TREE_OPERAND (ei->expr, i));
else
v = use;

--- 1979,1985 ----
if (!DECL_P (TREE_OPERAND (ei->expr, i)))
continue;
if (ref_type (use) & E_USE)
! v = find_rhs_use_for_var (use, TREE_OPERAND (ei->expr, i));
else
v = use;

*************** repair_injury (ei, use, temp, orig_euse)
*** 1966,1971 ****
--- 1992,2013 ----
continue;
while (is_injuring_def (ei, ref_expr (v)))
{
+ add_ref_to_list_begin (toprocess, v);
+ v = find_rhs_use_for_var (v, TREE_OPERAND (ei->expr, i));
+ if (ref_type (imm_reaching_def (v)) & M_DEFAULT
+ || ref_type (imm_reaching_def (v)) & V_PHI
+ || !maybe_find_rhs_use_for_var (imm_reaching_def (v),
+ TREE_OPERAND (ei->expr, i)))
+ break;
+ v = find_rhs_use_for_var (imm_reaching_def (v),
+ TREE_OPERAND (ei->expr, i));
+ }
+
+ /* The *first* reference will probably not have a reaching def we can
+ set yet, since it'll come from a save that hasn't been done
+ yet. */
+ FOR_EACH_REF (v, tmp, toprocess)
+ {
if (htab_find (ei->repaired, ref_expr (v)) == NULL)
{
#if DEBUGGING_STRRED
*************** repair_injury (ei, use, temp, orig_euse)
*** 1981,1998 ****
fold (build (PLUS_EXPR,
TREE_TYPE (temp),
temp, incr)));
! stmt = build_stmt (EXPR_STMT, expr);
TREE_TYPE (stmt) = TREE_TYPE (expr);
bb = ref_bb (use);
!
! #if 0
! insert_stmt_tree_after (stmt, ref_stmt (v), bb);
! #endif
*(htab_find_slot (ei->repaired, ref_expr (v), INSERT)) = ref_expr (v);
!
/* Update SSA for the repair.
1. Find the refs in the statement.
! 2. Updating the reaching defs of each use.
3. Insert into new statement map the tuple (orig_euse,
repair stmt).
*/
--- 2023,2039 ----
fold (build (PLUS_EXPR,
TREE_TYPE (temp),
temp, incr)));
! stmt = build (COMPOUND_EXPR, void_type_node, ref_stmt (v), expr);
TREE_TYPE (stmt) = TREE_TYPE (expr);
bb = ref_bb (use);
! replace_ref_stmt_with (v, stmt);
*(htab_find_slot (ei->repaired, ref_expr (v), INSERT)) = ref_expr (v);
! #if WAITING_FOR_DFA_UPDATE
/* Update SSA for the repair.
1. Find the refs in the statement.
! 2. Add the ref to the list of refs to find reaching defs
! for later (we don't necessarily have the eventual defs
! inserted yet).
3. Insert into new statement map the tuple (orig_euse,
repair stmt).
*/
*************** repair_injury (ei, use, temp, orig_euse)
*** 2000,2024 ****
create_ref is not correct. We should keep statement and
expression pointers here. */
find_refs_in_stmt (stmt, bb);
! FOR_EACH_REF (tempref, tmp, tree_refs (stmt))
! {
! if (!(ref_type (tempref) & V_USE))
! continue;
! find_reaching_def_of_var (tempref, bb, NULL);
! }
!
splay_tree_insert (new_stmt_map,
(splay_tree_key) orig_euse,
(splay_tree_value) stmt);
}
- v = find_rhs_use_for_var (v, TREE_OPERAND (ei->expr, i));
- if (ref_type (imm_reaching_def (v)) & M_DEFAULT
- || ref_type (imm_reaching_def (v)) & V_PHI
- || !maybe_find_rhs_use_for_var (imm_reaching_def (v),
- TREE_OPERAND (ei->expr, i)))
- break;
- v = find_rhs_use_for_var (imm_reaching_def (v),
- TREE_OPERAND (ei->expr, i));
}
}
else if (ref_type (imm_reaching_def (v)) & V_PHI)
--- 2041,2053 ----
create_ref is not correct. We should keep statement and
expression pointers here. */
find_refs_in_stmt (stmt, bb);
! add_ref_to_list_begin (ei->injfixups,
! find_def_for_stmt (stmt));
splay_tree_insert (new_stmt_map,
(splay_tree_key) orig_euse,
(splay_tree_value) stmt);
+ #endif
}
}
}
else if (ref_type (imm_reaching_def (v)) & V_PHI)
*************** repair_injury (ei, use, temp, orig_euse)
*** 2029,2107 ****
curr_phi_operand < num_phi_args (phi);
curr_phi_operand++)
{
! tree_ref phi_op = phi_arg_def (phi_arg (phi, curr_phi_operand));
tree_ref ephi = phi_at_block (ei, ref_bb (phi));
tree_ref ephi_op = phi_operand (ephi,
! phi_arg_edge (phi_arg (phi, curr_phi_operand))->src);
repair_injury (ei, phi_op, temp, ephi_op);
}
}
else
! {
! while (is_injuring_def (ei, ref_expr (imm_reaching_def (v))))
! {
! if (htab_find (ei->repaired,
! ref_expr (imm_reaching_def (v))) == NULL)
! {
!
! #if DEBUGGING_STRRED
! if (dump_file)
! {
! fprintf (dump_file, "Injuring def to repair is: ");
! print_generic_node (dump_file,ref_expr (imm_reaching_def (v)));
! fprintf (dump_file, "\n");
! }
!
! #endif
! incr = calculate_increment (ei,
! ref_expr (imm_reaching_def (v)));
! expr = build_modify_expr (temp, NOP_EXPR,
! fold (build (PLUS_EXPR,
! TREE_TYPE (temp),
! temp, incr)));
! stmt = build_stmt (EXPR_STMT, expr);
! TREE_TYPE (stmt) = TREE_TYPE (expr);
! bb = ref_bb (use);
! #if 0
! insert_stmt_tree_after (stmt,
! ref_stmt (imm_reaching_def (v)),
! bb);
! #endif
! *(htab_find_slot (ei->repaired,
! ref_expr (imm_reaching_def (v)), INSERT)) = imm_reaching_def (v);
! /* Update SSA for the repair.
! 1. Find the refs in the statement.
! 2. Updating the reaching defs of each use.
! 3. Insert into new statement map the tuple (orig_euse,
! repair stmt).
! */
! /* FIXME: Hack. Passing the address of local trees to
! create_ref is not correct. We should keep statement and
! expression pointers here. */
! find_refs_in_stmt (stmt, bb);
! FOR_EACH_REF (tempref, tmp, tree_refs (stmt))
! {
! if (!(ref_type (tempref) & V_USE))
! continue;
! find_reaching_def_of_var (tempref, bb, NULL);
! }
! splay_tree_insert (new_stmt_map,
! (splay_tree_key) orig_euse,
! (splay_tree_value) stmt);
! }
!
! v = find_rhs_use_for_var (imm_reaching_def (v),
! TREE_OPERAND (ei->expr, i));
! if (ref_type (imm_reaching_def (v)) & M_DEFAULT
! ||ref_type (imm_reaching_def (v)) & V_PHI
! || !maybe_find_rhs_use_for_var (imm_reaching_def (v),
! TREE_OPERAND (ei->expr, i)))
!
! break;
! v = find_rhs_use_for_var (imm_reaching_def (v),
! TREE_OPERAND (ei->expr, i));
! }
! }
}
}

--- 2058,2073 ----
curr_phi_operand < num_phi_args (phi);
curr_phi_operand++)
{
! phi_node_arg phi_oper = phi_arg (phi, curr_phi_operand);
! tree_ref phi_op = phi_arg_def (phi_oper);
tree_ref ephi = phi_at_block (ei, ref_bb (phi));
tree_ref ephi_op = phi_operand (ephi,
! phi_arg_edge (phi_oper)->src);
repair_injury (ei, phi_op, temp, ephi_op);
}
}
else
! abort ();
}
}

*************** find_reaching_def_of_var (var, stmtbb, p
*** 2116,2121 ****
--- 2082,2092 ----
{
tree_ref tempref;
struct ref_list_node *tmp;
+ struct ref_list_node *thisref;
+ struct ref_list_node *fromhere;
+
+ if (!stmtbb)
+ return NULL;

if (phi)
FOR_EACH_REF (tempref, tmp, bb_refs (ref_bb (phi)))
*************** find_reaching_def_of_var (var, stmtbb, p
*** 2136,2144 ****
return 1;
}
}
! FOR_EACH_REF_REV (tempref, tmp, bb_refs (stmtbb))
{
! if (!(ref_type (tempref) & (V_DEF | V_USE)) || tempref == var)
continue;
if (ref_var (tempref) == ref_var (var))
{
--- 2107,2126 ----
return 1;
}
}
!
! /* If this is the bb of the var, we start looking *before* the var */
! fromhere = bb_refs (stmtbb)->last;
! if (ref_bb (var) == stmtbb)
{
! thisref = find_list_node (bb_refs (stmtbb), var);
! if (thisref)
! fromhere = thisref;
! }
!
! FOR_REF_BETWEEN (tempref, tmp, fromhere, bb_refs (stmtbb)->first->prev, prev)
! {
! if (!(ref_type (tempref) & (V_DEF | V_USE))
! || ref_expr (var) == ref_expr (tempref))
continue;
if (ref_var (tempref) == ref_var (var))
{
*************** find_reaching_def_of_var (var, stmtbb, p
*** 2152,2158 ****
set_imm_reaching_def (var, tempref);
add_ref_to_list_end (imm_uses (tempref), var);
}
-
return 1;
}
}
--- 2134,2139 ----
*************** update_ssa_for_new_use (temp, newuse, de
*** 2175,2184 ****
{
tree_ref tempref;
struct ref_list_node *tmp;
! splay_tree_node orignode, reachingnode;
tree_ref use_orig_ref;
tree_ref olddefref, newdefref, newuseref;
tree reachingstmt;
ref_list todelete = create_ref_list ();
ref_list reachedtoadd = create_ref_list ();
ref_list immtoadd = create_ref_list ();
--- 2156,2166 ----
{
tree_ref tempref;
struct ref_list_node *tmp;
! splay_tree_node reachingnode;
tree_ref use_orig_ref;
tree_ref olddefref, newdefref, newuseref;
tree reachingstmt;
+ tree newmodifyexpr, useexpr;
ref_list todelete = create_ref_list ();
ref_list reachedtoadd = create_ref_list ();
ref_list immtoadd = create_ref_list ();
*************** update_ssa_for_new_use (temp, newuse, de
*** 2201,2212 ****
of the def of the assignment expression we just created for
this save.

! This is a bit simplified, since when i update a reaching def, we update the
! reaching def's immediate uses, etc.
*/

! orignode = splay_tree_lookup (orig_expr_map, (splay_tree_key) newuse);
! FOR_EACH_REF (tempref, tmp, tree_refs ((tree)orignode->value))
{
if (ref_type (tempref) & V_DEF)
{
--- 2183,2193 ----
of the def of the assignment expression we just created for
this save.

! This is a bit simplified, since when i update a reaching def, we update
! the reaching def's immediate uses, etc.
*/

! FOR_EACH_REF (tempref, tmp, tree_refs (newuse))
{
if (ref_type (tempref) & V_DEF)
{
*************** update_ssa_for_new_use (temp, newuse, de
*** 2214,2219 ****
--- 2195,2201 ----
break;
}
}
+ #if WAITING_FOR_DFA_UPDATE
olddefref = find_def_for_stmt (ref_stmt (use_orig_ref));
FOR_EACH_REF (tempref, tmp, tree_refs (ref_expr (use_orig_ref)))
{
*************** update_ssa_for_new_use (temp, newuse, de
*** 2244,2252 ****
remove_tree_ref (ref_expr (use_orig_ref), tempref);
}
ref_expr (use_orig_ref)->common.ann = NULL;
- #if 0
- replace_expr_in_tree (ref_stmt (use_orig_ref), newuse, temp);
#endif
/* FIXME: Hack. Passing the address of local trees to create_ref is not
correct. We should keep statement and expression pointers here. */
newdefref = create_ref (TREE_OPERAND (ref_expr (use_orig_ref), 0),
--- 2226,2240 ----
remove_tree_ref (ref_expr (use_orig_ref), tempref);
}
ref_expr (use_orig_ref)->common.ann = NULL;
#endif
+ useexpr = ref_expr (use_orig_ref);
+ STRIP_WFL (useexpr);
+ newmodifyexpr = build_modify_expr (TREE_OPERAND (useexpr, 0),
+ NOP_EXPR, temp);
+ replace_ref_expr_with (use_orig_ref, newmodifyexpr);
+
+ #if WAITING_FOR_DFA_UPDATE
+
/* FIXME: Hack. Passing the address of local trees to create_ref is not
correct. We should keep statement and expression pointers here. */
newdefref = create_ref (TREE_OPERAND (ref_expr (use_orig_ref), 0),
*************** update_ssa_for_new_use (temp, newuse, de
*** 2262,2273 ****

/* FIXME: Hack. Passing the address of local trees to create_ref is not
correct. We should keep statement and expression pointers here. */
- #if 0
newuseref = create_ref (temp, V_USE, bb, ref_stmt (use_orig_ref),
ref_expr (use_orig_ref),
find_expr_in_tree (ref_expr (use_orig_ref), temp),
true);
- #endif
if (! (ref_type (defby) & E_PHI))
{
/* For non-PHI's we created, the map is euse expression -> new pretmp
--- 2250,2259 ----
*************** update_ssa_for_new_use (temp, newuse, de
*** 2299,2307 ****
add_ref_to_list_end (reached_uses (reachingphi), newuseref);
add_ref_to_list_end (imm_uses (reachingphi), newuseref);
}
! }
!


/* Update all the phi argument definitions in REFS so that arguments defined by
OLD are now defined by NEW. */
--- 2285,2293 ----
add_ref_to_list_end (reached_uses (reachingphi), newuseref);
add_ref_to_list_end (imm_uses (reachingphi), newuseref);
}
! #endif

+ }

/* Update all the phi argument definitions in REFS so that arguments defined by
OLD are now defined by NEW. */
*************** code_motion (ei, temp)
*** 2336,2342 ****
--- 2322,2331 ----
{
fibheap_t exprs;
tree_ref use;
+ struct ref_list_node *tmp;
+ tree_ref tempref;

+ ei->injfixups = create_ref_list ();
need_repair_map = splay_tree_new (splay_tree_compare_pointers, NULL, NULL);
exprs = fibheap_new ();
if (ei->strred_cand)
*************** code_motion (ei, temp)
*** 2357,2365 ****
insert_euse_in_preorder_dt_order (ei, exprs);
while (!fibheap_empty (exprs))
{
- struct ref_list_node *tmp;
- tree_ref tempref;
-
use = fibheap_extract_min (exprs);
if (ref_type (use) & E_USE /*&& !EXPRUSE_PHIOP (use) */
&& !exprref_inserted (use))
--- 2346,2351 ----
*************** code_motion (ei, temp)
*** 2374,2387 ****
tree use_expr = ref_expr (use);
tree_ref use_orig_ref = NULL;
tree newexpr, newstmt;

! splay_tree_node orignode;
! orignode =
! splay_tree_lookup (orig_expr_map, (splay_tree_key) use_expr);
! if (!orignode)
! abort();
!
! FOR_EACH_REF (tempref, tmp, tree_refs ((tree)orignode->value))
{
if (ref_type (tempref) & V_DEF)
{
--- 2360,2370 ----
tree use_expr = ref_expr (use);
tree_ref use_orig_ref = NULL;
tree newexpr, newstmt;
+ struct ref_list_node *tmp2;
+ tree_ref a;
+ size_t j;

! FOR_EACH_REF (tempref, tmp, tree_refs (use_expr))
{
if (ref_type (tempref) & V_DEF)
{
*************** code_motion (ei, temp)
*** 2396,2411 ****
{
fprintf (dump_file, "In BB %d, insert save of ",
use_bb->index);
! print_generic_tree (dump_file, use_expr);
fprintf (dump_file, " to ");
print_generic_tree (dump_file, temp);
fprintf (dump_file, " before statement ");
print_generic_tree (dump_file, TREE_OPERAND (use_stmt, 0));
! fprintf (dump_file, " on line %d\n", STMT_LINENO (use_stmt));
}
newexpr = fold (build_modify_expr (temp, NOP_EXPR,
! deep_copy_node (use_expr)));
! newstmt = build_stmt (EXPR_STMT, newexpr);
/* Update the SSA representation for the new def of the
temporary.
1. Create the defs and uses for the new statement.
--- 2378,2412 ----
{
fprintf (dump_file, "In BB %d, insert save of ",
use_bb->index);
! print_generic_tree (dump_file, ei->expr);
fprintf (dump_file, " to ");
print_generic_tree (dump_file, temp);
fprintf (dump_file, " before statement ");
print_generic_tree (dump_file,TREE_OPERAND (use_stmt, 0));
! fprintf (dump_file, " on line %d\n",
! EXPR_WFL_LINENO (use_expr));
}
+ STRIP_WFL (use_expr);
newexpr = fold (build_modify_expr (temp, NOP_EXPR,
! deep_copy_node (TREE_OPERAND (use_expr, 1))));
! newstmt = build (COMPOUND_EXPR, void_type_node, newexpr,
! use_stmt);
! replace_ref_stmt_with (use, newstmt);
! use->common.stmt_p = &TREE_OPERAND (newstmt, 1);
! use->common.expr_p = &TREE_OPERAND (newstmt, 1);
! /* REMOVE AFTER DFA UPDATE */
! FOR_EACH_REF (a, tmp2, tree_refs (use_stmt))
! {
! if (ref_stmt (a) == newstmt)
! {
! a->common.stmt_p = &TREE_OPERAND (newstmt, 1);
! a->common.expr_p = &TREE_OPERAND (newstmt, 1);
! }
! }
! /* END REMOVE AFTER DFA UPDATE */
! update_ssa_for_new_use (temp, ref_expr (use), use, use_bb);
!
! #if WAITING_FOR_DFA_UPDATE
/* Update the SSA representation for the new def of the
temporary.
1. Create the defs and uses for the new statement.
*************** code_motion (ei, temp)
*** 2429,2437 ****
set_imm_reaching_def (tempref, olddef);
}

- #if 0
- insert_stmt_tree_before (newstmt, use_stmt, use_bb);
- #endif
splay_tree_insert (new_stmt_map,
(splay_tree_key) ref_expr (use),
(splay_tree_value) newstmt);
--- 2430,2435 ----
*************** code_motion (ei, temp)
*** 2443,2449 ****
dump_ref_list (dump_file, "", tree_refs (use_stmt), 0, 1);
}
#endif
!
}
else if (exprref_reload (use))
{
--- 2441,2447 ----
dump_ref_list (dump_file, "", tree_refs (use_stmt), 0, 1);
}
#endif
! #endif
}
else if (exprref_reload (use))
{
*************** code_motion (ei, temp)
*** 2454,2465 ****
{
fprintf (dump_file, "In BB %d, insert reload of ",
use_bb->index);
! print_generic_tree (dump_file, use_expr);
fprintf (dump_file, " from ");
print_generic_tree (dump_file, temp);
fprintf (dump_file, " in statement ");
print_generic_tree (dump_file, TREE_OPERAND (use_stmt, 0));
! fprintf (dump_file, " on line %d\n", STMT_LINENO (use_stmt));
}
/* Update the SSA representation for a new use of the temporary.
Do exactly what we do for the new use generated by the save.
--- 2452,2464 ----
{
fprintf (dump_file, "In BB %d, insert reload of ",
use_bb->index);
! print_generic_tree (dump_file, ei->expr);
fprintf (dump_file, " from ");
print_generic_tree (dump_file, temp);
fprintf (dump_file, " in statement ");
print_generic_tree (dump_file, TREE_OPERAND (use_stmt, 0));
! fprintf (dump_file, " on line %d\n",
! EXPR_WFL_LINENO (use_stmt));
}
/* Update the SSA representation for a new use of the temporary.
Do exactly what we do for the new use generated by the save.
*************** code_motion (ei, temp)
*** 2475,2480 ****
--- 2474,2480 ----
#endif
}
}
+ #if WAITING_FOR_DFA_UPDATE
else if (ref_type (use) & E_PHI)
{
/* E_PHI's become real PHI's of the temporary. */
*************** code_motion (ei, temp)
*** 2482,2487 ****
--- 2482,2493 ----
tree_ref phiop;
size_t i;
splay_tree_node phidefnode, defbynode;
+ #if DEBUGGING_SSA_UPDATE
+ if (dump_file)
+ {
+ fprintf (dump_file, "Creating a new phi for an EPHI\n");
+ }
+ #endif

/* FIXME: Hack. Passing the address of local trees to
create_ref is not correct. We should keep statement and
*************** code_motion (ei, temp)
*** 2557,2562 ****
--- 2563,2591 ----
}
}
}
+ #endif
+ #if WAITING_FOR_DFA_UPDATE
+ FOR_EACH_REF (tempref, tmp, ei->injfixups)
+ {
+ tree_ref tempref2;
+ struct ref_list_node *tmp2;
+
+ FOR_EACH_REF (tempref2, tmp2, tree_refs (ref_expr (tempref)))
+ {
+ if (!(ref_type (tempref2) & V_USE))
+ continue;
+ find_reaching_def_of_var (tempref2, ref_bb (tempref2), NULL);
+ #if DEBUGGING_SSA_UPDATE
+ if (dump_file)
+ {
+ fprintf (dump_file, "Injury use and new reaching def:\n");
+ dump_ref (dump_file, "", tempref2, 0, 1);
+ }
+ #endif
+ }
+ #endif
+ }
+
free (avdefs);
splay_tree_delete (need_repair_map);
}
*************** add_call_to_ei (slot, data)
*** 2578,2585 ****
{
tree_ref call = (tree_ref) data;
struct expr_info *ei = (struct expr_info *) slot;
! VARRAY_PUSH_TREE (ei->occurs, ref_expr (call));
! VARRAY_PUSH_TREE (ei->occurstmts, ref_stmt (call));
VARRAY_PUSH_GENERIC_PTR (ei->refs, call);
return 0;
}
--- 2607,2614 ----
{
tree_ref call = (tree_ref) data;
struct expr_info *ei = (struct expr_info *) slot;
! VARRAY_PUSH_GENERIC_PTR (ei->occurs, call->common.expr_p);
! VARRAY_PUSH_GENERIC_PTR (ei->occurstmts, call->common.stmt_p);
VARRAY_PUSH_GENERIC_PTR (ei->refs, call);
return 0;
}
*************** pre_part_1_trav (slot, data)
*** 2591,2597 ****
void *data;
{
tree temp;
!
struct expr_info *ei = (struct expr_info *) slot;
if (VARRAY_ACTIVE_SIZE (ei->reals) < 2)
return 0;
--- 2620,2626 ----
void *data;
{
tree temp;
! tree fnbody;
struct expr_info *ei = (struct expr_info *) slot;
if (VARRAY_ACTIVE_SIZE (ei->reals) < 2)
return 0;
*************** pre_part_1_trav (slot, data)
*** 2626,2636 ****
else
type_of_expr = TREE_TYPE (VARRAY_TREE (ei->reals, 0));

- pushlevel (0);
temp = create_tmp_var (type_of_expr, "pretmp");
- declare_tmp_vars (getdecls(),
- COMPOUND_BODY (DECL_SAVED_TREE (current_function_decl)));
- poplevel (1, 1, 0);
finalize_1 (ei, temp);
finalize_2 (ei);
code_motion (ei, temp);
--- 2655,2661 ----
*************** pre_part_1_trav (slot, data)
*** 2639,2646 ****
return 0;
}

! static
! void calculate_preorder ()
{
edge *stack;
int sp;
--- 2664,2671 ----
return 0;
}

! static void
! calculate_preorder ()
{
edge *stack;
int sp;
*************** tree_perform_ssapre ()
*** 2711,2717 ****
basic_block bb;
size_t j, k;

- orig_expr_map = splay_tree_new (splay_tree_compare_pointers, NULL, NULL);
new_stmt_map = splay_tree_new (splay_tree_compare_pointers, NULL, NULL);

VARRAY_GENERIC_PTR_INIT (bexprs, 1, "bexprs");
--- 2737,2742 ----
*************** tree_perform_ssapre ()
*** 2741,2754 ****
tree stmt = ref_stmt (ref);
if (!(ref_type (ref) & V_USE))
continue;
! if (htab_find (seen, expr) != NULL)
continue;
if (is_simple_modify_expr (expr))
{
- splay_tree_insert (orig_expr_map,
- (splay_tree_key) TREE_OPERAND (expr, 1),
- (splay_tree_value) expr);
-
expr = TREE_OPERAND (expr, 1);
}
if ((is_simple_binary_expr (expr)
--- 2766,2776 ----
tree stmt = ref_stmt (ref);
if (!(ref_type (ref) & V_USE))
continue;
! STRIP_WFL (expr);
! if (htab_find (seen, orig_expr) != NULL)
continue;
if (is_simple_modify_expr (expr))
{
expr = TREE_OPERAND (expr, 1);
}
if ((is_simple_binary_expr (expr)
*************** tree_perform_ssapre ()
*** 2757,2763 ****
&& TREE_CODE (expr) != INDIRECT_REF
&& !is_simple_condexpr (expr))
{
! struct expr_info *slot;
size_t k;
for (k = 0; k < VARRAY_ACTIVE_SIZE (bexprs); k++)
{
--- 2779,2785 ----
&& TREE_CODE (expr) != INDIRECT_REF
&& !is_simple_condexpr (expr))
{
! struct expr_info *slot = NULL;
size_t k;
for (k = 0; k < VARRAY_ACTIVE_SIZE (bexprs); k++)
{
*************** tree_perform_ssapre ()
*** 2769,2776 ****
slot = NULL;
if (slot)
{
! VARRAY_PUSH_TREE (slot->occurs, expr);
! VARRAY_PUSH_TREE (slot->occurstmts, stmt);
VARRAY_PUSH_TREE (slot->reals, expr);
VARRAY_PUSH_TREE (slot->realstmts, stmt);
VARRAY_PUSH_GENERIC_PTR (slot->refs, ref);
--- 2791,2798 ----
slot = NULL;
if (slot)
{
! VARRAY_PUSH_GENERIC_PTR (slot->occurs, ref->common.expr_p);
! VARRAY_PUSH_GENERIC_PTR (slot->occurstmts, ref->common.stmt_p);
VARRAY_PUSH_TREE (slot->reals, expr);
VARRAY_PUSH_TREE (slot->realstmts, stmt);
VARRAY_PUSH_GENERIC_PTR (slot->refs, ref);
*************** tree_perform_ssapre ()
*** 2780,2787 ****
{
slot = ggc_alloc (sizeof (struct expr_info));
slot->expr = expr;
! VARRAY_TREE_INIT (slot->occurs, 1, "Kills and occurrence");
! VARRAY_TREE_INIT (slot->occurstmts, 1,
"Kills and occurrence statements");
VARRAY_TREE_INIT (slot->reals, 1, "Real occurrences");
VARRAY_TREE_INIT (slot->realstmts, 1,
--- 2802,2809 ----
{
slot = ggc_alloc (sizeof (struct expr_info));
slot->expr = expr;
! VARRAY_GENERIC_PTR_INIT (slot->occurs, 1, "Kills and occurrence");
! VARRAY_GENERIC_PTR_INIT (slot->occurstmts, 1,
"Kills and occurrence statements");
VARRAY_TREE_INIT (slot->reals, 1, "Real occurrences");
VARRAY_TREE_INIT (slot->realstmts, 1,
*************** tree_perform_ssapre ()
*** 2790,2797 ****
"EPHIs");
VARRAY_GENERIC_PTR_INIT (slot->erefs, 1, "EREFs");
VARRAY_GENERIC_PTR_INIT (slot->refs, 1, "REFs");
! VARRAY_PUSH_TREE (slot->occurs, expr);
! VARRAY_PUSH_TREE (slot->occurstmts, stmt);
VARRAY_PUSH_TREE (slot->reals, expr);
VARRAY_PUSH_TREE (slot->realstmts, stmt);
VARRAY_PUSH_GENERIC_PTR (slot->refs, ref);
--- 2812,2819 ----
"EPHIs");
VARRAY_GENERIC_PTR_INIT (slot->erefs, 1, "EREFs");
VARRAY_GENERIC_PTR_INIT (slot->refs, 1, "REFs");
! VARRAY_PUSH_GENERIC_PTR (slot->occurs, ref->common.expr_p);
! VARRAY_PUSH_GENERIC_PTR (slot->occurstmts, ref->common.stmt_p);
VARRAY_PUSH_TREE (slot->reals, expr);
VARRAY_PUSH_TREE (slot->realstmts, stmt);
VARRAY_PUSH_GENERIC_PTR (slot->refs, ref);
*************** tree_perform_ssapre ()
*** 2811,2817 ****
add_call_to_ei (VARRAY_GENERIC_PTR (bexprs, k), ref);
}
}
! *(htab_find_slot (seen, ref_expr (ref), INSERT)) = ref_expr (ref);
}
}
for (j = 0; j < VARRAY_ACTIVE_SIZE (bexprs); j++)
--- 2833,2839 ----
add_call_to_ei (VARRAY_GENERIC_PTR (bexprs, k), ref);
}
}
! *(htab_find_slot (seen, orig_expr, INSERT)) = orig_expr;
}
}
for (j = 0; j < VARRAY_ACTIVE_SIZE (bexprs); j++)
*************** tree_perform_ssapre ()
*** 2838,2844 ****
free (pre_preorder);
sbitmap_vector_free (pre_dfs);
sbitmap_vector_free (domchildren);
! splay_tree_delete (orig_expr_map);
splay_tree_delete (new_stmt_map);

}
--- 2860,2866 ----
free (pre_preorder);
sbitmap_vector_free (pre_dfs);
sbitmap_vector_free (domchildren);
!
splay_tree_delete (new_stmt_map);

}



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