* [patch] Clean up scattered uses of PENDING_STMT.
@ 2004-10-26 21:21 Kazu Hirata
2004-10-28 12:43 ` Diego Novillo
0 siblings, 1 reply; 2+ messages in thread
From: Kazu Hirata @ 2004-10-26 21:21 UTC (permalink / raw)
To: gcc-patches
Hi,
Attached is a patch to clean up scattered uses of PENDING_STMT.
ssa_redirect_edge stores in PENDING_STMT PHI arguments removed from an
edge.
Now, there are *five* places where people try to put those PHI
arguments back to a new edge. Most notably,
nestify_update_pending_stmts and lv_update_pending_stmts are exactly
the same function.
The patch cleans up all of these places and merge them into a single
function called flush_pending_stmts.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2004-10-25 Kazu Hirata <kazu@cs.umass.edu>
* lambda-code.c (nestify_update_pending_stmts): Remove.
(perfect_nestify): Use flush_pending_stmts instead of
nestify_update_pending_stmts.
* tree-cfg.c (tree_make_forwarder_block): Use
flush_pending_stmts.
* tree-flow.h: Add a prototype for flush_pending_stmts.
* tree-ssa-loop-manip.c (tree_duplicate_loop_to_header_edge):
Use flush_pending_stmts.
(lv_update_pending_stmts): Remove.
(tree_ssa_loop_version): Use flush_pending_stmts instead of
lv_update_pending_stmts.
* tree-ssa.c (flush_pending_stmts): New.
Index: lambda-code.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/lambda-code.c,v
retrieving revision 2.15
diff -u -p -r2.15 lambda-code.c
--- lambda-code.c 22 Oct 2004 17:05:05 -0000 2.15
+++ lambda-code.c 26 Oct 2004 13:38:10 -0000
@@ -2109,31 +2109,6 @@ perfect_nest_p (struct loop *loop)
return true;
}
-
-/* Add phi args using PENDINT_STMT list. */
-
-static void
-nestify_update_pending_stmts (edge e)
-{
- basic_block dest;
- tree phi, arg, def;
-
- if (!PENDING_STMT (e))
- return;
-
- dest = e->dest;
-
- for (phi = phi_nodes (dest), arg = PENDING_STMT (e);
- phi;
- phi = TREE_CHAIN (phi), arg = TREE_CHAIN (arg))
- {
- def = TREE_VALUE (arg);
- add_phi_arg (&phi, def, e);
- }
-
- PENDING_STMT (e) = NULL;
-}
-
/* Replace the USES of tree X in STMT with tree Y */
static void
@@ -2317,7 +2292,7 @@ perfect_nestify (struct loops *loops,
add_phi_arg (&phi, def, EDGE_PRED (preheaderbb, 0));
}
- nestify_update_pending_stmts (e);
+ flush_pending_stmts (e);
bodybb = create_empty_bb (EXIT_BLOCK_PTR->prev_bb);
latchbb = create_empty_bb (EXIT_BLOCK_PTR->prev_bb);
make_edge (headerbb, bodybb, EDGE_FALLTHRU);
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.89
diff -u -p -r2.89 tree-cfg.c
--- tree-cfg.c 23 Oct 2004 19:17:08 -0000 2.89
+++ tree-cfg.c 26 Oct 2004 13:38:11 -0000
@@ -3692,12 +3692,7 @@ tree_make_forwarder_block (edge fallthru
if (e == fallthru)
continue;
- for (phi = phi_nodes (bb), var = PENDING_STMT (e);
- phi;
- phi = PHI_CHAIN (phi), var = TREE_CHAIN (var))
- add_phi_arg (&phi, TREE_VALUE (var), e);
-
- PENDING_STMT (e) = NULL;
+ flush_pending_stmts (e);
}
}
@@ -4592,7 +4587,7 @@ tree_duplicate_sese_region (edge entry,
struct loop *loop = entry->dest->loop_father;
edge exit_copy;
bitmap definitions;
- tree phi, var;
+ tree phi;
basic_block *doms;
htab_t ssa_name_map = NULL;
edge redirected;
@@ -4661,11 +4656,7 @@ tree_duplicate_sese_region (edge entry,
/* Redirect the entry and add the phi node arguments. */
redirected = redirect_edge_and_branch (entry, entry->dest->rbi->copy);
gcc_assert (redirected != NULL);
- for (phi = phi_nodes (entry->dest), var = PENDING_STMT (entry);
- phi;
- phi = TREE_CHAIN (phi), var = TREE_CHAIN (var))
- add_phi_arg (&phi, TREE_VALUE (var), entry);
- PENDING_STMT (entry) = NULL;
+ flush_pending_stmts (entry);
/* Concerning updating of dominators: We must recount dominators
for entry block and its copy. Anything that is outside of the region, but
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.54
diff -u -p -r2.54 tree-flow.h
--- tree-flow.h 25 Oct 2004 22:04:02 -0000 2.54
+++ tree-flow.h 26 Oct 2004 13:38:11 -0000
@@ -572,6 +572,7 @@ extern void dump_tree_ssa_stats (FILE *)
extern void debug_tree_ssa_stats (void);
extern void ssa_remove_edge (edge);
extern edge ssa_redirect_edge (edge, basic_block);
+extern void flush_pending_stmts (edge e);
extern bool tree_ssa_useless_type_conversion (tree);
extern bool tree_ssa_useless_type_conversion_1 (tree, tree);
extern void verify_ssa (void);
Index: tree-ssa-loop-manip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-manip.c,v
retrieving revision 2.11
diff -u -p -r2.11 tree-ssa-loop-manip.c
--- tree-ssa-loop-manip.c 25 Oct 2004 21:46:18 -0000 2.11
+++ tree-ssa-loop-manip.c 26 Oct 2004 13:38:11 -0000
@@ -589,7 +589,6 @@ tree_duplicate_loop_to_header_edge (stru
unsigned first_new_block;
basic_block bb;
unsigned i;
- tree phi, arg, map, def;
bitmap definitions;
if (!(loops->state & LOOPS_HAVE_SIMPLE_LATCHES))
@@ -609,17 +608,7 @@ tree_duplicate_loop_to_header_edge (stru
return false;
/* Readd the removed phi args for e. */
- map = PENDING_STMT (e);
- PENDING_STMT (e) = NULL;
-
- for (phi = phi_nodes (e->dest), arg = map;
- phi;
- phi = TREE_CHAIN (phi), arg = TREE_CHAIN (arg))
- {
- def = TREE_VALUE (arg);
- add_phi_arg (&phi, def, e);
- }
- gcc_assert (arg == NULL);
+ flush_pending_stmts (e);
/* Copy the phi node arguments. */
copy_phi_node_args (first_new_block);
@@ -747,31 +736,6 @@ lv_adjust_loop_entry_edge (basic_block f
return new_head;
}
-/* Add phi args using PENDINT_STMT list. */
-
-static void
-lv_update_pending_stmts (edge e)
-{
- basic_block dest;
- tree phi, arg, def;
-
- if (!PENDING_STMT (e))
- return;
-
- dest = e->dest;
-
- for (phi = phi_nodes (dest), arg = PENDING_STMT (e);
- phi;
- phi = TREE_CHAIN (phi), arg = TREE_CHAIN (arg))
- {
- def = TREE_VALUE (arg);
- add_phi_arg (&phi, def, e);
- }
-
- PENDING_STMT (e) = NULL;
-}
-
-
/* Main entry point for Loop Versioning transformation.
This transformation given a condition and a loop, creates
@@ -832,11 +796,11 @@ tree_ssa_loop_version (struct loops *loo
nloop->single_exit = find_edge (exit->src->rbi->copy, exit->dest);
/* loopify redirected latch_edge. Update its PENDING_STMTS. */
- lv_update_pending_stmts (latch_edge);
+ flush_pending_stmts (latch_edge);
/* loopify redirected condition_bb's succ edge. Update its PENDING_STMTS. */
extract_true_false_edges_from_block (*condition_bb, &true_edge, &false_edge);
- lv_update_pending_stmts (false_edge);
+ flush_pending_stmts (false_edge);
/* Adjust irreducible flag. */
if (irred_flag)
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.49
diff -u -p -r2.49 tree-ssa.c
--- tree-ssa.c 18 Oct 2004 18:01:10 -0000 2.49
+++ tree-ssa.c 26 Oct 2004 13:38:12 -0000
@@ -100,6 +100,27 @@ ssa_redirect_edge (edge e, basic_block d
return e;
}
+/* Add PHI arguments queued in PENDINT_STMT list on edge E to edge
+ E->dest. */
+
+void
+flush_pending_stmts (edge e)
+{
+ tree phi, arg;
+
+ if (!PENDING_STMT (e))
+ return;
+
+ for (phi = phi_nodes (e->dest), arg = PENDING_STMT (e);
+ phi;
+ phi = TREE_CHAIN (phi), arg = TREE_CHAIN (arg))
+ {
+ tree def = TREE_VALUE (arg);
+ add_phi_arg (&phi, def, e);
+ }
+
+ PENDING_STMT (e) = NULL;
+}
/* Return true if SSA_NAME is malformed and mark it visited.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch] Clean up scattered uses of PENDING_STMT.
2004-10-26 21:21 [patch] Clean up scattered uses of PENDING_STMT Kazu Hirata
@ 2004-10-28 12:43 ` Diego Novillo
0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2004-10-28 12:43 UTC (permalink / raw)
To: Kazu Hirata; +Cc: gcc-patches
On Tue, 2004-10-26 at 15:31, Kazu Hirata wrote:
> * lambda-code.c (nestify_update_pending_stmts): Remove.
> (perfect_nestify): Use flush_pending_stmts instead of
> nestify_update_pending_stmts.
> * tree-cfg.c (tree_make_forwarder_block): Use
> flush_pending_stmts.
> * tree-flow.h: Add a prototype for flush_pending_stmts.
> * tree-ssa-loop-manip.c (tree_duplicate_loop_to_header_edge):
> Use flush_pending_stmts.
> (lv_update_pending_stmts): Remove.
> (tree_ssa_loop_version): Use flush_pending_stmts instead of
> lv_update_pending_stmts.
> * tree-ssa.c (flush_pending_stmts): New.
>
OK. Thanks.
Diego.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-10-28 12:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-26 21:21 [patch] Clean up scattered uses of PENDING_STMT Kazu Hirata
2004-10-28 12:43 ` Diego Novillo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).