This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 67/89] Make gimple_phi_arg_location require a gimple_phi.
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Mon, 21 Apr 2014 12:57:38 -0400
- Subject: [PATCH 67/89] Make gimple_phi_arg_location require a gimple_phi.
- Authentication-results: sourceware.org; auth=none
- References: <1398099480-49147-1-git-send-email-dmalcolm at redhat dot com>
gcc/
* gimple.h (gimple_phi_arg_location): Require a gimple_phi.
* tree-into-ssa.c (rewrite_update_phi_arguments): Replace a check
for code GIMPLE_PHI with a dyn_cast and a new local.
* tree-ssa-ter.c (ter_is_replaceable_p): Likewise.
* tree-ssa-live.c (remove_unused_locals): Replace a
gimple_stmt_iterator with a gimple_phi_iterator, using it to make
local "phi" be a gimple_phi.
* tree-ssa-phiopt.c (tree_ssa_phiopt_worker): Likewise.
* tree-ssa-phiopt.c (conditional_replacement): Require a gimple_phi.
(single_non_singleton_phi_for_edges): Return a gimple_phi; update
local to be a gimple_phi, adding checked casts since we're working
on a sequence of gimple_phi.
(conditional_replacement): Require a gimple_phi.
---
gcc/gimple.h | 6 +++---
gcc/tree-into-ssa.c | 7 ++++---
gcc/tree-ssa-live.c | 6 ++++--
gcc/tree-ssa-phiopt.c | 17 +++++++++--------
gcc/tree-ssa-ter.c | 4 ++--
5 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/gcc/gimple.h b/gcc/gimple.h
index becd273..db3f425 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4250,12 +4250,12 @@ gimple_phi_arg_edge (gimple_phi phi, size_t i)
return EDGE_PRED (gimple_bb (phi), i);
}
-/* Return the source location of gimple argument I of phi node GS. */
+/* Return the source location of gimple argument I of phi node PHI. */
static inline source_location
-gimple_phi_arg_location (gimple gs, size_t i)
+gimple_phi_arg_location (gimple_phi phi, size_t i)
{
- return gimple_phi_arg (gs, i)->locus;
+ return gimple_phi_arg (phi, i)->locus;
}
/* Return the source location of the argument on edge E of phi node PHI. */
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 217adeb..47f6832 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -2044,12 +2044,13 @@ rewrite_update_phi_arguments (basic_block bb)
else
{
gimple stmt = SSA_NAME_DEF_STMT (reaching_def);
+ gimple_phi other_phi = stmt->dyn_cast_gimple_phi ();
/* Single element PHI nodes behave like copies, so get the
location from the phi argument. */
- if (gimple_code (stmt) == GIMPLE_PHI
- && gimple_phi_num_args (stmt) == 1)
- locus = gimple_phi_arg_location (stmt, 0);
+ if (other_phi
+ && gimple_phi_num_args (other_phi) == 1)
+ locus = gimple_phi_arg_location (other_phi, 0);
else
locus = gimple_location (stmt);
}
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 3223a71..3274552 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -821,12 +821,14 @@ remove_unused_locals (void)
mark_all_vars_used (gimple_op_ptr (gsi_stmt (gsi), i));
}
- for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ for (gimple_phi_iterator gpi = gsi_start_phis (bb);
+ !gsi_end_p (gpi);
+ gsi_next (&gpi))
{
use_operand_p arg_p;
ssa_op_iter i;
tree def;
- gimple phi = gsi_stmt (gsi);
+ gimple_phi phi = gpi.phi ();
if (virtual_operand_p (gimple_phi_result (phi)))
continue;
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index b8ed719..6fa68cd 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -62,7 +62,7 @@ along with GCC; see the file COPYING3. If not see
static unsigned int tree_ssa_phiopt (void);
static unsigned int tree_ssa_phiopt_worker (bool, bool);
static bool conditional_replacement (basic_block, basic_block,
- edge, edge, gimple, tree, tree);
+ edge, edge, gimple_phi, tree, tree);
static int value_replacement (basic_block, basic_block,
edge, edge, gimple, tree, tree);
static bool minmax_replacement (basic_block, basic_block,
@@ -294,16 +294,16 @@ tree_ssa_cs_elim (void)
/* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */
-static gimple
+static gimple_phi
single_non_singleton_phi_for_edges (gimple_seq seq, edge e0, edge e1)
{
gimple_stmt_iterator i;
- gimple phi = NULL;
+ gimple_phi phi = NULL;
if (gimple_seq_singleton_p (seq))
- return gsi_stmt (gsi_start (seq));
+ return gsi_stmt (gsi_start (seq))->as_a_gimple_phi ();
for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
{
- gimple p = gsi_stmt (i);
+ gimple_phi p = gsi_stmt (i)->as_a_gimple_phi ();
/* If the PHI arguments are equal then we can skip this PHI. */
if (operand_equal_for_phi_arg_p (gimple_phi_arg_def (p, e0->dest_idx),
gimple_phi_arg_def (p, e1->dest_idx)))
@@ -367,7 +367,8 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads)
for (i = 0; i < n; i++)
{
- gimple cond_stmt, phi;
+ gimple cond_stmt;
+ gimple_phi phi;
basic_block bb1, bb2;
edge e1, e2;
tree arg0, arg1;
@@ -478,7 +479,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads)
so try that first. */
for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
{
- phi = gsi_stmt (gsi);
+ phi = gsi_stmt (gsi)->as_a_gimple_phi ();
arg0 = gimple_phi_arg_def (phi, e1->dest_idx);
arg1 = gimple_phi_arg_def (phi, e2->dest_idx);
if (value_replacement (bb, bb1, e1, e2, phi, arg0, arg1) == 2)
@@ -589,7 +590,7 @@ replace_phi_edge_with_variable (basic_block cond_block,
static bool
conditional_replacement (basic_block cond_bb, basic_block middle_bb,
- edge e0, edge e1, gimple phi,
+ edge e0, edge e1, gimple_phi phi,
tree arg0, tree arg1)
{
tree result;
diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
index 09dc313..3c8c531 100644
--- a/gcc/tree-ssa-ter.c
+++ b/gcc/tree-ssa-ter.c
@@ -428,8 +428,8 @@ ter_is_replaceable_p (gimple stmt)
block1 = LOCATION_BLOCK (locus1);
locus1 = LOCATION_LOCUS (locus1);
- if (gimple_code (use_stmt) == GIMPLE_PHI)
- locus2 = gimple_phi_arg_location (use_stmt,
+ if (gimple_phi phi = use_stmt->dyn_cast_gimple_phi ())
+ locus2 = gimple_phi_arg_location (phi,
PHI_ARG_INDEX_FROM_USE (use_p));
else
locus2 = gimple_location (use_stmt);
--
1.8.5.3