Commit 5ae71719 by Kazu Hirata Committed by Kazu Hirata

tree-phinodes.c (phi_reverse): New.

	* tree-phinodes.c (phi_reverse): New.
	* tree-cfg.c (tree_make_forwarder_block, tree_duplicate_bb):
	Use it.
	* tree-flow.h: Add a prototype for phi_reverse.

From-SVN: r90344
parent 6571838f
2004-11-09 Kazu Hirata <kazu@cs.umass.edu> 2004-11-09 Kazu Hirata <kazu@cs.umass.edu>
* tree-phinodes.c (phi_reverse): New.
* tree-cfg.c (tree_make_forwarder_block, tree_duplicate_bb):
Use it.
* tree-flow.h: Add a prototype for phi_reverse.
2004-11-09 Kazu Hirata <kazu@cs.umass.edu>
* tree-ssa-loop-ivopts.c: Fix a comment typo. * tree-ssa-loop-ivopts.c: Fix a comment typo.
2004-11-09 James A. Morrison <phython@gcc.gnu.org> 2004-11-09 James A. Morrison <phython@gcc.gnu.org>
......
...@@ -3655,7 +3655,7 @@ tree_make_forwarder_block (edge fallthru) ...@@ -3655,7 +3655,7 @@ tree_make_forwarder_block (edge fallthru)
edge e; edge e;
edge_iterator ei; edge_iterator ei;
basic_block dummy, bb; basic_block dummy, bb;
tree phi, new_phi, var, prev, next; tree phi, new_phi, var;
dummy = fallthru->src; dummy = fallthru->src;
bb = fallthru->dest; bb = fallthru->dest;
...@@ -3675,14 +3675,7 @@ tree_make_forwarder_block (edge fallthru) ...@@ -3675,14 +3675,7 @@ tree_make_forwarder_block (edge fallthru)
} }
/* Ensure that the PHI node chain is in the same order. */ /* Ensure that the PHI node chain is in the same order. */
prev = NULL; set_phi_nodes (bb, phi_reverse (phi_nodes (bb)));
for (phi = phi_nodes (bb); phi; phi = next)
{
next = PHI_CHAIN (phi);
PHI_CHAIN (phi) = prev;
prev = phi;
}
set_phi_nodes (bb, prev);
/* Add the arguments we have stored on edges. */ /* Add the arguments we have stored on edges. */
FOR_EACH_EDGE (e, ei, bb->preds) FOR_EACH_EDGE (e, ei, bb->preds)
...@@ -4281,7 +4274,7 @@ tree_duplicate_bb (basic_block bb) ...@@ -4281,7 +4274,7 @@ tree_duplicate_bb (basic_block bb)
mark_for_rewrite (PHI_RESULT (phi)); mark_for_rewrite (PHI_RESULT (phi));
create_phi_node (PHI_RESULT (phi), new_bb); create_phi_node (PHI_RESULT (phi), new_bb);
} }
set_phi_nodes (new_bb, nreverse (phi_nodes (new_bb))); set_phi_nodes (new_bb, phi_reverse (phi_nodes (new_bb)));
bsi_tgt = bsi_start (new_bb); bsi_tgt = bsi_start (new_bb);
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi)) for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
......
...@@ -516,6 +516,7 @@ extern void remove_phi_arg (tree, basic_block); ...@@ -516,6 +516,7 @@ extern void remove_phi_arg (tree, basic_block);
extern void remove_phi_arg_num (tree, int); extern void remove_phi_arg_num (tree, int);
extern void remove_phi_node (tree, tree, basic_block); extern void remove_phi_node (tree, tree, basic_block);
extern void remove_all_phi_nodes_for (bitmap); extern void remove_all_phi_nodes_for (bitmap);
extern tree phi_reverse (tree);
extern void dump_dfa_stats (FILE *); extern void dump_dfa_stats (FILE *);
extern void debug_dfa_stats (void); extern void debug_dfa_stats (void);
extern void debug_referenced_vars (void); extern void debug_referenced_vars (void);
......
...@@ -491,6 +491,21 @@ remove_all_phi_nodes_for (bitmap vars) ...@@ -491,6 +491,21 @@ remove_all_phi_nodes_for (bitmap vars)
} }
} }
/* Reverse the order of PHI nodes in the chain PHI.
Return the new head of the chain (old last PHI node). */
tree
phi_reverse (tree phi)
{
tree prev = NULL_TREE, next;
for (; phi; phi = next)
{
next = PHI_CHAIN (phi);
PHI_CHAIN (phi) = prev;
prev = phi;
}
return prev;
}
#include "gt-tree-phinodes.h" #include "gt-tree-phinodes.h"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment