This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa][PATCH]: Add bsi_move_*
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Diego Novillo <dnovillo at redhat dot com>,gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 15 Aug 2003 19:32:40 -0400
- Subject: [tree-ssa][PATCH]: Add bsi_move_*
This patch adds bsi_move_after, bsi_move_before, and
bsi_move_to_end_of_bb.
The last is a convenience function that chooses the right bsi_move
depending on what the statement at the end of the block is.
Dominator and loop hoisters will want to move to the end of the bb, so
it seems to make sense.
Bootstrapped on i686 on tree-ssa branch,though nothing uses it.
Bootstrapped a version for tree-ssa-cfg with loop LICM running (the
patch has the same movement conditions and movement code, the removal
call is slightly different due to the cell structure) to verify it
worked okay.
2003-08-15 Daniel Berlin <dberlin@dberlin.org>
* tree-cfg (bsi_move_after): New function.
(bsi_move_before): New function.
(bsi_move_to_bb_end): New function.
* tree-flow.h: Prototype new functions.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.148
diff -u -3 -p -r1.1.4.148 tree-cfg.c
--- tree-cfg.c 15 Aug 2003 12:51:19 -0000 1.1.4.148
+++ tree-cfg.c 15 Aug 2003 23:20:48 -0000
@@ -2099,6 +2099,44 @@ bsi_remove (block_stmt_iterator *i)
remove_bsi_from_block (i, true);
}
+/* Move the statement at FROM so it comes right after the statement at
+ TO. */
+void
+bsi_move_after (block_stmt_iterator from, block_stmt_iterator to)
+{
+ tree stmt = bsi_stmt (from);
+ remove_bsi_from_block (&from, false);
+ bsi_insert_after (&to, stmt, BSI_SAME_STMT);
+}
+
+/* Move the statement at FROM so it comes right before the statement
+ at TO. */
+void
+bsi_move_before (block_stmt_iterator from, block_stmt_iterator to)
+{
+ tree stmt = bsi_stmt (from);
+ remove_bsi_from_block (&from, false);
+ bsi_insert_before (&to, stmt, BSI_SAME_STMT);
+}
+
+/* Move the statement at FROM to the end of basic block BB, */
+void
+bsi_move_to_bb_end (block_stmt_iterator from, basic_block bb)
+{
+ block_stmt_iterator last = bsi_last (bb);
+
+ /* Have to check bsi_end_p because it could be an empty block. */
+ if (!bsi_end_p (last)
+ && (is_ctrl_altering_stmt (bsi_stmt (last))
+ || is_ctrl_stmt (bsi_stmt (last))))
+ {
+ bsi_move_before (from, last);
+ }
+ else
+ {
+ bsi_move_after (from, last);
+ }
+}
/* Replace the contents of a stmt with another. The replacement cannot
be
a COMPOUND_EXPR node, only a gimple stmt. */
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.102
diff -u -3 -p -r1.1.4.102 tree-flow.h
--- tree-flow.h 15 Aug 2003 15:38:27 -0000 1.1.4.102
+++ tree-flow.h 15 Aug 2003 23:20:48 -0000
@@ -416,3 +416,6 @@ extern int call_expr_flags (tree);
extern int remove_useless_stmts_and_vars (tree *, int);
extern int could_trap_p (tree);
extern basic_block tree_split_edge (edge);
+extern void bsi_move_before (block_stmt_iterator, block_stmt_iterator);
+extern void bsi_move_after (block_stmt_iterator, block_stmt_iterator);
+extern void bsi_move_to_bb_end (block_stmt_iterator, basic_block);