* 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.
From-SVN: r89234
+2004-10-18  Diego Novillo  <dnovillo@redhat.com>
+
+       * 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.
+
 2004-10-18  Diego Novillo  <dnovillo@redhat.com>
 
        PR tree-optimization/17656
 
                  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);
 
 /* Finds iterator for STMT.  */
 
 extern block_stmt_iterator
-stmt_for_bsi (tree stmt)
+bsi_for_stmt (tree stmt)
 {
   block_stmt_iterator bsi;
 
 
 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 *);
 
     }
   else
     {
-      block_stmt_iterator bsi = stmt_for_bsi (stmt);
+      block_stmt_iterator bsi = bsi_for_stmt (stmt);
 
       bsi_remove (&bsi);
     }
 
     case MODIFY_EXPR:
       tgt = TREE_OPERAND (use->stmt, 0);
-      bsi = stmt_for_bsi (use->stmt);
+      bsi = bsi_for_stmt (use->stmt);
       break;
 
     default:
 {
   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);
 
 {
   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,
 
          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);
            }
        }