return false;
}
+
+/* For each PHI in BB, copy the argument associated with SRC_E to TGT_E.
+ Assuming the argument exists, just does not have a value. */
+
+void
+copy_phi_arg_into_existing_phi (edge src_e, edge tgt_e)
+{
+ int src_idx = src_e->dest_idx;
+ int tgt_idx = tgt_e->dest_idx;
+
+ /* Iterate over each PHI in e->dest. */
+ for (gphi_iterator gsi = gsi_start_phis (src_e->dest),
+ gsi2 = gsi_start_phis (tgt_e->dest);
+ !gsi_end_p (gsi);
+ gsi_next (&gsi), gsi_next (&gsi2))
+ {
+ gphi *src_phi = gsi.phi ();
+ gphi *dest_phi = gsi2.phi ();
+ tree val = gimple_phi_arg_def (src_phi, src_idx);
+ location_t locus = gimple_phi_arg_location (src_phi, src_idx);
+
+ SET_PHI_ARG_DEF (dest_phi, tgt_idx, val);
+ gimple_phi_arg_set_location (dest_phi, tgt_idx, locus);
+ }
+}
+
/* Duplicates REGION consisting of N_REGION blocks. The new blocks
are stored to REGION_COPY in the same order in that they appear
in REGION, if REGION_COPY is not NULL. ENTRY is the entry to
gimple_stmt_iterator gsi;
edge sorig, snew;
basic_block exit_bb;
- gphi_iterator psi;
- gphi *phi;
- tree def;
class loop *target, *aloop, *cloop;
gcc_assert (EDGE_COUNT (exit->src->succs) == 2);
gcc_assert (single_succ_edge (region_copy[i]));
e = redirect_edge_and_branch (single_succ_edge (region_copy[i]), exit_bb);
PENDING_STMT (e) = NULL;
- for (psi = gsi_start_phis (exit_bb);
- !gsi_end_p (psi);
- gsi_next (&psi))
- {
- phi = psi.phi ();
- def = PHI_ARG_DEF (phi, nexits[0]->dest_idx);
- add_phi_arg (phi, def, e, gimple_phi_arg_location_from_edge (phi, e));
- }
+ copy_phi_arg_into_existing_phi (nexits[0], e);
}
e = redirect_edge_and_branch (nexits[1], nexits[0]->dest);
PENDING_STMT (e) = NULL;
extern edge gimple_switch_edge (function *, gswitch *, unsigned);
extern edge gimple_switch_default_edge (function *, gswitch *);
extern bool cond_only_block_p (basic_block);
+extern void copy_phi_arg_into_existing_phi (edge, edge);
/* Return true if the LHS of a call should be removed. */
if (s == e)
{
- /* Create arguments for the phi nodes, since the edge was not
+ /* Copy arguments for the phi nodes, since the edge was not
here before. */
- for (gphi_iterator psi = gsi_start_phis (dest);
- !gsi_end_p (psi);
- gsi_next (&psi))
- {
- gphi *phi = psi.phi ();
- location_t l = gimple_phi_arg_location_from_edge (phi, succ);
- tree def = gimple_phi_arg_def (phi, succ->dest_idx);
- add_phi_arg (phi, unshare_expr (def), s, l);
- }
+ copy_phi_arg_into_existing_phi (succ, s);
}
}
}
}
-/* Similar to copy_phi_args, except that the PHI arg exists, it just
- does not have a value associated with it. */
-
-static void
-copy_phi_arg_into_existing_phi (edge src_e, edge tgt_e)
-{
- int src_idx = src_e->dest_idx;
- int tgt_idx = tgt_e->dest_idx;
-
- /* Iterate over each PHI in e->dest. */
- for (gphi_iterator gsi = gsi_start_phis (src_e->dest),
- gsi2 = gsi_start_phis (tgt_e->dest);
- !gsi_end_p (gsi);
- gsi_next (&gsi), gsi_next (&gsi2))
- {
- gphi *src_phi = gsi.phi ();
- gphi *dest_phi = gsi2.phi ();
- tree val = gimple_phi_arg_def (src_phi, src_idx);
- location_t locus = gimple_phi_arg_location (src_phi, src_idx);
-
- SET_PHI_ARG_DEF (dest_phi, tgt_idx, val);
- gimple_phi_arg_set_location (dest_phi, tgt_idx, locus);
- }
-}
-
/* Given ssa_name DEF, backtrack jump threading PATH from node IDX
to see if it has constant value in a flow sensitive manner. Set
LOCUS to location of the constant phi arg and return the value.