[PATCH 4/4] Add get_virtual_phi
2015-06-18 Tom de Vries <tom@codesourcery.com>
* tree-ssa-loop-manip.c (get_virtual_phi): Factor out of ...
(rewrite_virtuals_into_loop_closed_ssa): ... here.
---
gcc/tree-ssa-loop-manip.c | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
@@ -603,44 +603,43 @@ replace_uses_in_dominated_bbs (tree old_val, tree new_val, basic_block bb)
BITMAP_FREE (dominated);
}
-/* Ensure a virtual phi is present in the exit block, if LOOP contains a vdef.
- In other words, ensure loop-closed ssa normal form for virtuals. */
+/* Return the virtual phi in BB. */
-void
-rewrite_virtuals_into_loop_closed_ssa (struct loop *loop)
+static gphi *
+get_virtual_phi (basic_block bb)
{
gphi *phi;
- edge exit = single_dom_exit (loop);
phi = NULL;
- for (gphi_iterator gsi = gsi_start_phis (loop->header);
+ for (gphi_iterator gsi = gsi_start_phis (bb);
!gsi_end_p (gsi);
gsi_next (&gsi))
{
if (virtual_operand_p (PHI_RESULT (gsi.phi ())))
{
- phi = gsi.phi ();
- break;
+ return gsi.phi ();
}
}
+ return NULL;
+}
+
+/* Ensure a virtual phi is present in the exit block, if LOOP contains a vdef.
+ In other words, ensure loop-closed ssa normal form for virtuals. */
+
+void
+rewrite_virtuals_into_loop_closed_ssa (struct loop *loop)
+{
+ gphi *phi;
+ edge exit = single_dom_exit (loop);
+
+ phi = get_virtual_phi (loop->header);
if (phi == NULL)
return;
tree final_loop = PHI_ARG_DEF_FROM_EDGE (phi, single_succ_edge (loop->latch));
- phi = NULL;
- for (gphi_iterator gsi = gsi_start_phis (exit->dest);
- !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- if (virtual_operand_p (PHI_RESULT (gsi.phi ())))
- {
- phi = gsi.phi ();
- break;
- }
- }
-
+ phi = get_virtual_phi (exit->dest);
if (phi != NULL)
{
tree final_exit = PHI_ARG_DEF_FROM_EDGE (phi, exit);
--
1.9.1