public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1646] Remove create_lcssa_for_virtual_phi and uses
@ 2022-07-12 12:40 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-07-12 12:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9b06b9d23799ecad5db710e80f214fac0ae175f3

commit r13-1646-g9b06b9d23799ecad5db710e80f214fac0ae175f3
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jul 12 14:37:51 2022 +0200

    Remove create_lcssa_for_virtual_phi and uses
    
    The following expands the comment in vect_do_peeling as to why we
    do not need create_lcssa_for_virtual_phi and removes that function.
    
    That's the last bit I have queued for the vectorizer virtual LCSSA
    cleanup.
    
            * tree-vect-loop-manip.cc (create_lcssa_for_virtual_phi):
            Remove.
            (vect_do_peeling): Do not call it, adjust comment.

Diff:
---
 gcc/tree-vect-loop-manip.cc | 95 ++++-----------------------------------------
 1 file changed, 7 insertions(+), 88 deletions(-)

diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 2c2b4f7bd53..86d2264054a 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -1332,56 +1332,6 @@ slpeel_can_duplicate_loop_p (const class loop *loop, const_edge e)
   return true;
 }
 
-/* If the loop has a virtual PHI, but exit bb doesn't, create a virtual PHI
-   in the exit bb and rename all the uses after the loop.  This simplifies
-   the *guard[12] routines, which assume loop closed SSA form for all PHIs
-   (but normally loop closed SSA form doesn't require virtual PHIs to be
-   in the same form).  Doing this early simplifies the checking what
-   uses should be renamed.
-
-   If we create a new phi after the loop, return the definition that
-   applies on entry to the loop, otherwise return null.  */
-
-static tree
-create_lcssa_for_virtual_phi (class loop *loop)
-{
-  gphi_iterator gsi;
-  edge exit_e = single_exit (loop);
-
-  for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
-    if (virtual_operand_p (gimple_phi_result (gsi_stmt (gsi))))
-      {
-	gphi *phi = gsi.phi ();
-	for (gsi = gsi_start_phis (exit_e->dest);
-	     !gsi_end_p (gsi); gsi_next (&gsi))
-	  if (virtual_operand_p (gimple_phi_result (gsi_stmt (gsi))))
-	    break;
-	if (gsi_end_p (gsi))
-	  {
-	    tree new_vop = copy_ssa_name (PHI_RESULT (phi));
-	    gphi *new_phi = create_phi_node (new_vop, exit_e->dest);
-	    tree vop = PHI_ARG_DEF_FROM_EDGE (phi, EDGE_SUCC (loop->latch, 0));
-	    imm_use_iterator imm_iter;
-	    gimple *stmt;
-	    use_operand_p use_p;
-
-	    SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_vop)
-	      = SSA_NAME_OCCURS_IN_ABNORMAL_PHI (vop);
-	    add_phi_arg (new_phi, vop, exit_e, UNKNOWN_LOCATION);
-	    gimple_phi_set_result (new_phi, new_vop);
-	    FOR_EACH_IMM_USE_STMT (stmt, imm_iter, vop)
-	      if (stmt != new_phi
-		  && !flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
-		FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
-		  SET_USE (use_p, new_vop);
-
-	    return PHI_ARG_DEF_FROM_EDGE (phi, loop_preheader_edge (loop));
-	  }
-	break;
-      }
-  return NULL_TREE;
-}
-
 /* Function vect_get_loop_location.
 
    Extract the location of the loop in the source code.
@@ -2702,31 +2652,20 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
      pending update needs.  */
   gcc_assert (!need_ssa_update_p (cfun));
 
-  create_lcssa_for_virtual_phi (loop);
-
-  /* If we're vectorizing an epilogue loop, the update_ssa above will
-     have ensured that the virtual operand is in SSA form throughout the
-     vectorized main loop.  Normally it is possible to trace the updated
+  /* If we're vectorizing an epilogue loop, we have ensured that the
+     virtual operand is in SSA form throughout the vectorized main loop.
+     Normally it is possible to trace the updated
      vector-stmt vdefs back to scalar-stmt vdefs and vector-stmt vuses
      back to scalar-stmt vuses, meaning that the effect of the SSA update
      remains local to the main loop.  However, there are rare cases in
-     which the vectorized loop has vdefs even when the original scalar
+     which the vectorized loop should have vdefs even when the original scalar
      loop didn't.  For example, vectorizing a load with IFN_LOAD_LANES
      introduces clobbers of the temporary vector array, which in turn
      needs new vdefs.  If the scalar loop doesn't write to memory, these
      new vdefs will be the only ones in the vector loop.
-
-     In that case, update_ssa will have added a new virtual phi to the
-     main loop, which previously didn't need one.  Ensure that we (locally)
-     maintain LCSSA form for the virtual operand, just as we would have
-     done if the virtual phi had existed from the outset.  This makes it
-     easier to duplicate the scalar epilogue loop below.  */
-  tree vop_to_rename = NULL_TREE;
-  if (loop_vec_info orig_loop_vinfo = LOOP_VINFO_ORIG_LOOP_INFO (loop_vinfo))
-    {
-      class loop *orig_loop = LOOP_VINFO_LOOP (orig_loop_vinfo);
-      vop_to_rename = create_lcssa_for_virtual_phi (orig_loop);
-    }
+     We are currently defering updating virtual SSA form and creating
+     of a virtual PHI for this case so we do not have to make sure the
+     newly introduced virtual def is in LCSSA form.  */
 
   if (MAY_HAVE_DEBUG_BIND_STMTS)
     {
@@ -2947,26 +2886,6 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
 	 as the transformations mentioned above make less or no sense when not
 	 vectorizing.  */
       epilog = vect_epilogues ? get_loop_copy (loop) : scalar_loop;
-      if (vop_to_rename)
-	{
-	  /* Vectorizing the main loop can sometimes introduce a vdef to
-	     a loop that previously didn't have one; see the comment above
-	     the definition of VOP_TO_RENAME for details.  The definition
-	     D that holds on E will then be different from the definition
-	     VOP_TO_RENAME that holds during SCALAR_LOOP, so we need to
-	     rename VOP_TO_RENAME to D when copying the loop.
-
-	     The virtual operand is in LCSSA form for the main loop,
-	     and no stmt between the main loop and E needs a vdef,
-	     so we know that D is provided by a phi rather than by a
-	     vdef on a normal gimple stmt.  */
-	  basic_block vdef_bb = e->src;
-	  gphi *vphi;
-	  while (!(vphi = get_virtual_phi (vdef_bb)))
-	    vdef_bb = get_immediate_dominator (CDI_DOMINATORS, vdef_bb);
-	  gcc_assert (vop_to_rename != gimple_phi_result (vphi));
-	  set_current_def (vop_to_rename, gimple_phi_result (vphi));
-	}
       epilog = slpeel_tree_duplicate_loop_to_edge_cfg (loop, epilog, e);
       if (!epilog)
 	{


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-12 12:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 12:40 [gcc r13-1646] Remove create_lcssa_for_virtual_phi and uses Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).