This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [lno] [PATCH] Loop Versioning
Hello,
> >this patch should fix this.
>
> It causes abort() at
>
> find_induction_variable() --> find_givs() -->
> get_loop_body_in_dom_order()
aw, sure (should not try sending untested patches this late in the
night). This one could be better.
Zdenek
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.244.2.5
diff -c -3 -p -r1.1.4.244.2.5 tree-cfg.c
*** tree-cfg.c 25 Jan 2004 20:20:15 -0000 1.1.4.244.2.5
--- tree-cfg.c 29 Jan 2004 23:31:15 -0000
*************** bsi_replace (const block_stmt_iterator *
*** 2571,2580 ****
In all cases, the returned *BSI points to the correct location. The
return value is true if insertion should be done after the location,
! or false if before the location. */
static bool
! tree_find_edge_insert_loc (edge e, block_stmt_iterator *bsi)
{
basic_block dest, src;
tree tmp;
--- 2571,2582 ----
In all cases, the returned *BSI points to the correct location. The
return value is true if insertion should be done after the location,
! or false if before the location. If new basic block has to be created,
! it is stored in *NEW_BB. */
static bool
! tree_find_edge_insert_loc (edge e, block_stmt_iterator *bsi,
! basic_block *new_bb)
{
basic_block dest, src;
tree tmp;
*************** tree_find_edge_insert_loc (edge e, block
*** 2635,2640 ****
--- 2637,2644 ----
/* Otherwise, create a new basic block, and split this edge. */
dest = split_edge (e);
+ if (new_bb)
+ *new_bb = dest;
e = dest->pred;
goto restart;
}
*************** bsi_commit_edge_inserts_1 (edge e)
*** 2677,2683 ****
PENDING_STMT (e) = NULL_TREE;
! if (tree_find_edge_insert_loc (e, &bsi))
bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
else
bsi_insert_before (&bsi, stmt, BSI_NEW_STMT);
--- 2681,2687 ----
PENDING_STMT (e) = NULL_TREE;
! if (tree_find_edge_insert_loc (e, &bsi, NULL))
bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
else
bsi_insert_before (&bsi, stmt, BSI_NEW_STMT);
*************** bsi_insert_on_edge (edge e, tree stmt)
*** 2694,2714 ****
append_to_statement_list (stmt, &PENDING_STMT (e));
}
! /* Similar to bsi_insert_on_edge+bsi_commit_edge_inserts. */
/* ??? Why in the world do we need this? Only PRE uses it. */
! void
bsi_insert_on_edge_immediate (edge e, tree stmt)
{
block_stmt_iterator bsi;
if (PENDING_STMT (e))
abort ();
! if (tree_find_edge_insert_loc (e, &bsi))
bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
else
bsi_insert_before (&bsi, stmt, BSI_NEW_STMT);
}
/*---------------------------------------------------------------------------
--- 2698,2722 ----
append_to_statement_list (stmt, &PENDING_STMT (e));
}
! /* Similar to bsi_insert_on_edge+bsi_commit_edge_inserts. If new block has to
! be created, it is returned. */
/* ??? Why in the world do we need this? Only PRE uses it. */
! basic_block
bsi_insert_on_edge_immediate (edge e, tree stmt)
{
block_stmt_iterator bsi;
+ basic_block new_bb = NULL;
if (PENDING_STMT (e))
abort ();
! if (tree_find_edge_insert_loc (e, &bsi, &new_bb))
bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
else
bsi_insert_before (&bsi, stmt, BSI_NEW_STMT);
+
+ return new_bb;
}
/*---------------------------------------------------------------------------
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.177.2.6
diff -c -3 -p -r1.1.4.177.2.6 tree-flow.h
*** tree-flow.h 25 Jan 2004 20:20:16 -0000 1.1.4.177.2.6
--- tree-flow.h 29 Jan 2004 23:31:15 -0000
*************** extern void tree_optimize_tail_calls (bo
*** 448,454 ****
extern edge tree_block_forwards_to (basic_block bb);
extern void bsi_insert_on_edge (edge, tree);
extern void bsi_commit_edge_inserts (int *);
! extern void bsi_insert_on_edge_immediate (edge, tree);
extern void notice_special_calls (tree);
extern void clear_special_calls (void);
extern void compute_dominance_frontiers (bitmap *);
--- 448,454 ----
extern edge tree_block_forwards_to (basic_block bb);
extern void bsi_insert_on_edge (edge, tree);
extern void bsi_commit_edge_inserts (int *);
! extern basic_block bsi_insert_on_edge_immediate (edge, tree);
extern void notice_special_calls (tree);
extern void clear_special_calls (void);
extern void compute_dominance_frontiers (bitmap *);
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-loop-ivopts.c,v
retrieving revision 1.1.2.2
diff -c -3 -p -r1.1.2.2 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c 25 Jan 2004 22:37:11 -0000 1.1.2.2
--- tree-ssa-loop-ivopts.c 29 Jan 2004 23:31:16 -0000
*************** create_new_iv (struct iv_cand *cand)
*** 2851,2857 ****
initial = force_gimple_operand (base, &stmts,
SSA_NAME_VAR (cand->var_before), false);
if (stmts)
! bsi_insert_on_edge_immediate (loop_preheader_edge (current_loop), stmts);
stmt = create_phi_node (cand->var_before, current_loop->header);
SSA_NAME_DEF_STMT (cand->var_before) = stmt;
--- 2851,2864 ----
initial = force_gimple_operand (base, &stmts,
SSA_NAME_VAR (cand->var_before), false);
if (stmts)
! {
! basic_block new_bb;
! edge pe = loop_preheader_edge (current_loop);
!
! new_bb = bsi_insert_on_edge_immediate (pe, stmts);
! if (new_bb)
! add_bb_to_loop (new_bb, new_bb->pred->src->loop_father);
! }
stmt = create_phi_node (cand->var_before, current_loop->header);
SSA_NAME_DEF_STMT (cand->var_before) = stmt;