Fix PR17656
Diego Novillo
dnovillo@redhat.com
Mon Oct 18 18:17:00 GMT 2004
On Mon, 2004-10-18 at 13:48, Richard Henderson wrote:
> On Mon, Oct 18, 2004 at 01:37:17PM -0400, Diego Novillo wrote:
> > fold_stmt (&tmp);
> > if (tmp != stmt)
> ...
> > + fold_stmt (bsi_stmt_ptr (si));
>
> Why are you re-folding? Can't you bsi_replace with tmp?
>
bsi_replace also seems to work. I have also renamed stmt_for_bsi into
something more meaningful.
Diego.
* tree-cfg.c (bsi_for_stmt): Rename from stmt_for_bsi.
Update all callers.
* tree-ssa.c (replace_immediate_uses): Call bsi_for_stmt.
Don't call fold_stmt more than once, use bsi_replace.
Index: lambda-code.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/lambda-code.c,v
retrieving revision 2.13
diff -d -c -p -u -r2.13 lambda-code.c
--- lambda-code.c 6 Oct 2004 19:40:54 -0000 2.13
+++ lambda-code.c 18 Oct 2004 17:54:35 -0000
@@ -1937,7 +1937,7 @@ lambda_loopnest_to_gcc_loopnest (struct
LBV_COEFFICIENTS (lbv)[i] = 1;
lbv = lambda_body_vector_compute_new (transform, lbv);
newiv = lbv_to_gcc_expression (lbv, new_ivs, &stmts);
- bsi = stmt_for_bsi (stmt);
+ bsi = bsi_for_stmt (stmt);
/* Insert the statements to build that
expression. */
bsi_insert_before (&bsi, stmts, BSI_SAME_STMT);
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.78
diff -d -c -p -u -r2.78 tree-cfg.c
--- tree-cfg.c 16 Oct 2004 16:58:59 -0000 2.78
+++ tree-cfg.c 18 Oct 2004 17:54:35 -0000
@@ -2638,7 +2638,7 @@ set_bb_for_stmt (tree t, basic_block bb)
/* Finds iterator for STMT. */
extern block_stmt_iterator
-stmt_for_bsi (tree stmt)
+bsi_for_stmt (tree stmt)
{
block_stmt_iterator bsi;
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.52
diff -d -c -p -u -r2.52 tree-flow.h
--- tree-flow.h 7 Oct 2004 23:31:04 -0000 2.52
+++ tree-flow.h 18 Oct 2004 17:54:35 -0000
@@ -416,7 +416,7 @@ typedef struct {
static inline block_stmt_iterator bsi_start (basic_block);
static inline block_stmt_iterator bsi_last (basic_block);
static inline block_stmt_iterator bsi_after_labels (basic_block);
-block_stmt_iterator stmt_for_bsi (tree);
+block_stmt_iterator bsi_for_stmt (tree);
static inline bool bsi_end_p (block_stmt_iterator);
static inline void bsi_next (block_stmt_iterator *);
static inline void bsi_prev (block_stmt_iterator *);
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.19
diff -d -c -p -u -r2.19 tree-ssa-loop-ivopts.c
--- tree-ssa-loop-ivopts.c 17 Oct 2004 23:13:21 -0000 2.19
+++ tree-ssa-loop-ivopts.c 18 Oct 2004 17:54:35 -0000
@@ -3878,7 +3878,7 @@ remove_statement (tree stmt, bool includ
}
else
{
- block_stmt_iterator bsi = stmt_for_bsi (stmt);
+ block_stmt_iterator bsi = bsi_for_stmt (stmt);
bsi_remove (&bsi);
}
@@ -3916,7 +3916,7 @@ rewrite_use_nonlinear_expr (struct ivopt
case MODIFY_EXPR:
tgt = TREE_OPERAND (use->stmt, 0);
- bsi = stmt_for_bsi (use->stmt);
+ bsi = bsi_for_stmt (use->stmt);
break;
default:
@@ -4055,7 +4055,7 @@ rewrite_use_address (struct ivopts_data
{
tree comp = unshare_expr (get_computation (data->current_loop,
use, cand));
- block_stmt_iterator bsi = stmt_for_bsi (use->stmt);
+ block_stmt_iterator bsi = bsi_for_stmt (use->stmt);
tree stmts;
tree op = force_gimple_operand (comp, &stmts, true, NULL_TREE);
@@ -4074,7 +4074,7 @@ rewrite_use_compare (struct ivopts_data
{
tree comp;
tree *op_p, cond, op, stmts, bound;
- block_stmt_iterator bsi = stmt_for_bsi (use->stmt);
+ block_stmt_iterator bsi = bsi_for_stmt (use->stmt);
enum tree_code compare;
if (may_eliminate_iv (data->current_loop,
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.48
diff -d -c -p -u -r2.48 tree-ssa.c
--- tree-ssa.c 18 Oct 2004 17:39:39 -0000 2.48
+++ tree-ssa.c 18 Oct 2004 17:54:36 -0000
@@ -1105,20 +1105,9 @@ replace_immediate_uses (tree var, tree r
fold_stmt (&tmp);
if (tmp != stmt)
{
- basic_block bb = bb_for_stmt (stmt);
- block_stmt_iterator si;
-
- /* Start iterating at the start of the basic block
- holding STMT until we reach it. This is slow, but
- it's the only way to get a statement pointer
- reliably. */
- for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
- if (bsi_stmt (si) == stmt)
- {
- fold_stmt (bsi_stmt_ptr (si));
- stmt = bsi_stmt (si);
- break;
- }
+ block_stmt_iterator si = bsi_for_stmt (stmt);
+ bsi_replace (&si, tmp, true);
+ stmt = bsi_stmt (si);
}
}
More information about the Gcc-patches
mailing list