@@ -1,5 +1,29 @@
2014-10-24 David Malcolm <dmalcolm@redhat.com>
+ Convert various gimple to gimple_phi within ssa-iterators.h
+
+ * ssa-iterators.h (FOR_EACH_PHI_OR_STMT_USE): Add checked cast to
+ gimple_phi.
+ (FOR_EACH_PHI_OR_STMT_DEF): Likewise.
+
+ * ssa-iterators.h (single_phi_def): Require a gimple_phi.
+ (op_iter_init_phiuse): Likewise.
+ (op_iter_init_phidef): Likewise.
+ * tree-ssa-loop-im.c (extract_true_false_args_from_phi): Likewise.
+
+ * tree-ssa-loop-im.c (link_use_stmts_after): Replace check against
+ GIMPLE_PHI with add a dyn_cast to gimple_phi, using result as needed.
+ (determine_max_movement): Likewise.
+ * tree-ssa-reassoc.c (is_phi_for_stmt): Likewise.
+ * tree-ssa-sccvn.c (start_over:): Likewise.
+
+ * tree-ssa-loop-im.c
+ (move_computations_dom_walker::before_dom_children): Split iterator
+ into gimple_stmt_iterator and a gimple_phi_iterator so that a local
+ can become a gimple_phi.
+
+2014-10-24 David Malcolm <dmalcolm@redhat.com>
+
Use gimple_phi in many more places.
* gimple-ssa-strength-reduction.c (slsr_process_phi): Require a
@@ -194,7 +194,9 @@ struct ssa_op_iter
a real stmt or a PHI node, looking at the USE nodes matching FLAGS. */
#define FOR_EACH_PHI_OR_STMT_USE(USEVAR, STMT, ITER, FLAGS) \
for ((USEVAR) = (gimple_code (STMT) == GIMPLE_PHI \
- ? op_iter_init_phiuse (&(ITER), STMT, FLAGS) \
+ ? op_iter_init_phiuse (&(ITER), \
+ as_a <gimple_phi> (STMT), \
+ FLAGS) \
: op_iter_init_use (&(ITER), STMT, FLAGS)); \
!op_iter_done (&(ITER)); \
(USEVAR) = op_iter_next_use (&(ITER)))
@@ -203,7 +205,9 @@ struct ssa_op_iter
a real stmt or a PHI node, looking at the DEF nodes matching FLAGS. */
#define FOR_EACH_PHI_OR_STMT_DEF(DEFVAR, STMT, ITER, FLAGS) \
for ((DEFVAR) = (gimple_code (STMT) == GIMPLE_PHI \
- ? op_iter_init_phidef (&(ITER), STMT, FLAGS) \
+ ? op_iter_init_phidef (&(ITER), \
+ as_a <gimple_phi> (STMT), \
+ FLAGS) \
: op_iter_init_def (&(ITER), STMT, FLAGS)); \
!op_iter_done (&(ITER)); \
(DEFVAR) = op_iter_next_def (&(ITER)))
@@ -749,7 +753,7 @@ num_ssa_operands (gimple stmt, int flags)
/* If there is a single DEF in the PHI node which matches FLAG, return it.
Otherwise return NULL_DEF_OPERAND_P. */
static inline tree
-single_phi_def (gimple stmt, int flags)
+single_phi_def (gimple_phi stmt, int flags)
{
tree def = PHI_RESULT (stmt);
if ((flags & SSA_OP_DEF) && is_gimple_reg (def))
@@ -762,7 +766,7 @@ single_phi_def (gimple stmt, int flags)
/* Initialize the iterator PTR for uses matching FLAGS in PHI. FLAGS should
be either SSA_OP_USES or SSA_OP_VIRTUAL_USES. */
static inline use_operand_p
-op_iter_init_phiuse (ssa_op_iter *ptr, gimple phi, int flags)
+op_iter_init_phiuse (ssa_op_iter *ptr, gimple_phi phi, int flags)
{
tree phi_def = gimple_phi_result (phi);
int comp;
@@ -792,7 +796,7 @@ op_iter_init_phiuse (ssa_op_iter *ptr, gimple phi, int flags)
/* Start an iterator for a PHI definition. */
static inline def_operand_p
-op_iter_init_phidef (ssa_op_iter *ptr, gimple phi, int flags)
+op_iter_init_phidef (ssa_op_iter *ptr, gimple_phi phi, int flags)
{
tree phi_def = PHI_RESULT (phi);
int comp;
@@ -881,9 +885,9 @@ link_use_stmts_after (use_operand_p head, imm_use_iterator *imm)
/* Only look at virtual or real uses, depending on the type of HEAD. */
flag = (is_gimple_reg (use) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
- if (gimple_code (head_stmt) == GIMPLE_PHI)
+ if (gimple_phi phi = dyn_cast <gimple_phi> (head_stmt))
{
- FOR_EACH_PHI_ARG (use_p, head_stmt, op_iter, flag)
+ FOR_EACH_PHI_ARG (use_p, phi, op_iter, flag)
if (USE_FROM_PTR (use_p) == use)
last_p = move_use_after_head (use_p, head, last_p);
}
@@ -622,7 +622,7 @@ mem_ref_in_stmt (gimple stmt)
else return false. */
static bool
-extract_true_false_args_from_phi (basic_block dom, gimple phi,
+extract_true_false_args_from_phi (basic_block dom, gimple_phi phi,
tree *true_arg_p, tree *false_arg_p)
{
basic_block bb = gimple_bb (phi);
@@ -705,7 +705,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
level = superloop_at_depth (loop, 1);
lim_data->max_loop = level;
- if (gimple_code (stmt) == GIMPLE_PHI)
+ if (gimple_phi phi = dyn_cast <gimple_phi> (stmt))
{
use_operand_p use_p;
unsigned min_cost = UINT_MAX;
@@ -716,7 +716,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
evaluated. For this reason the PHI cost (and thus the
cost we remove from the loop by doing the invariant motion)
is that of the cheapest PHI argument dependency chain. */
- FOR_EACH_PHI_ARG (use_p, stmt, iter, SSA_OP_USE)
+ FOR_EACH_PHI_ARG (use_p, phi, iter, SSA_OP_USE)
{
val = USE_FROM_PTR (use_p);
@@ -746,7 +746,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
min_cost = MIN (min_cost, total_cost);
lim_data->cost += min_cost;
- if (gimple_phi_num_args (stmt) > 1)
+ if (gimple_phi_num_args (phi) > 1)
{
basic_block dom = get_immediate_dominator (CDI_DOMINATORS, bb);
gimple cond;
@@ -758,7 +758,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
/* Verify that this is an extended form of a diamond and
the PHI arguments are completely controlled by the
predicate in DOM. */
- if (!extract_true_false_args_from_phi (dom, stmt, NULL, NULL))
+ if (!extract_true_false_args_from_phi (dom, phi, NULL, NULL))
return false;
/* Fold in dependencies and cost of the condition. */
@@ -1165,18 +1165,16 @@ void
move_computations_dom_walker::before_dom_children (basic_block bb)
{
struct loop *level;
- gimple_stmt_iterator bsi;
- gimple stmt;
unsigned cost = 0;
struct lim_aux_data *lim_data;
if (!loop_outer (bb->loop_father))
return;
- for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); )
+ for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi); )
{
gimple_assign new_stmt;
- stmt = gsi_stmt (bsi);
+ gimple_phi stmt = bsi.phi ();
lim_data = get_lim_data (stmt);
if (lim_data == NULL)
@@ -1230,11 +1228,11 @@ move_computations_dom_walker::before_dom_children (basic_block bb)
remove_phi_node (&bsi, false);
}
- for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); )
+ for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); )
{
edge e;
- stmt = gsi_stmt (bsi);
+ gimple stmt = gsi_stmt (bsi);
lim_data = get_lim_data (stmt);
if (lim_data == NULL)
@@ -3068,6 +3068,7 @@ static bool
is_phi_for_stmt (gimple stmt, tree operand)
{
gimple def_stmt;
+ gimple_phi def_phi;
tree lhs;
use_operand_p arg_p;
ssa_op_iter i;
@@ -3078,10 +3079,11 @@ is_phi_for_stmt (gimple stmt, tree operand)
lhs = gimple_assign_lhs (stmt);
def_stmt = SSA_NAME_DEF_STMT (operand);
- if (gimple_code (def_stmt) != GIMPLE_PHI)
+ def_phi = dyn_cast <gimple_phi> (def_stmt);
+ if (!def_phi)
return false;
- FOR_EACH_PHI_ARG (arg_p, def_stmt, i, SSA_OP_USE)
+ FOR_EACH_PHI_ARG (arg_p, def_phi, i, SSA_OP_USE)
if (lhs == USE_FROM_PTR (arg_p))
return true;
return false;
@@ -3934,8 +3934,8 @@ start_over:
if (!gimple_nop_p (defstmt))
{
/* Push a new iterator. */
- if (gimple_code (defstmt) == GIMPLE_PHI)
- usep = op_iter_init_phiuse (&iter, defstmt, SSA_OP_ALL_USES);
+ if (gimple_phi phi = dyn_cast <gimple_phi> (defstmt))
+ usep = op_iter_init_phiuse (&iter, phi, SSA_OP_ALL_USES);
else
usep = op_iter_init_use (&iter, defstmt, SSA_OP_ALL_USES);
}
This corresponds to: [PATCH 89/89] Convert various gimple to gimple_phi within ssa-iterators.h https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01177.html from the original 89-patch kit That earlier patch was approved by Jeff: > OK once prereq go in. in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00861.html gcc/ * ssa-iterators.h (FOR_EACH_PHI_OR_STMT_USE): Add checked cast to gimple_phi. (FOR_EACH_PHI_OR_STMT_DEF): Likewise. * ssa-iterators.h (single_phi_def): Require a gimple_phi. (op_iter_init_phiuse): Likewise. (op_iter_init_phidef): Likewise. * tree-ssa-loop-im.c (extract_true_false_args_from_phi): Likewise. * tree-ssa-loop-im.c (link_use_stmts_after): Replace check against GIMPLE_PHI with add a dyn_cast to gimple_phi, using result as needed. (determine_max_movement): Likewise. * tree-ssa-reassoc.c (is_phi_for_stmt): Likewise. * tree-ssa-sccvn.c (start_over:): Likewise. * tree-ssa-loop-im.c (move_computations_dom_walker::before_dom_children): Split iterator into gimple_stmt_iterator and a gimple_phi_iterator so that a local can become a gimple_phi. --- gcc/ChangeLog.gimple-classes | 24 ++++++++++++++++++++++++ gcc/ssa-iterators.h | 18 +++++++++++------- gcc/tree-ssa-loop-im.c | 20 +++++++++----------- gcc/tree-ssa-reassoc.c | 6 ++++-- gcc/tree-ssa-sccvn.c | 4 ++-- 5 files changed, 50 insertions(+), 22 deletions(-)