]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid PHI - PHI recurrence in vectorization
authorRichard Biener <rguenther@suse.de>
Thu, 20 Oct 2022 09:04:21 +0000 (11:04 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 20 Oct 2022 10:49:50 +0000 (12:49 +0200)
The reported regression of libgomp loop-14.C shows that there isn't
generally a good reliable place to insert the permute upfront so
the following simply restricts recurrence vectorization to the cases
where the latch value isn't defined by a PHI.

* tree-vect-loop.cc (vect_phi_first_order_recurrence_p):
Disallow latch PHI defs.
(vectorizable_recurr): Revert previous change.

gcc/tree-vect-loop.cc

index 92790bd80953457dcb0fa0d056cca3bd62a3aaa7..d5c2bff80be9be152707eb9d3932c863948daa73 100644 (file)
@@ -543,6 +543,7 @@ vect_phi_first_order_recurrence_p (loop_vec_info loop_vinfo, class loop *loop,
   tree ldef = PHI_ARG_DEF_FROM_EDGE (phi, latch);
   if (TREE_CODE (ldef) != SSA_NAME
       || SSA_NAME_IS_DEFAULT_DEF (ldef)
+      || is_a <gphi *> (SSA_NAME_DEF_STMT (ldef))
       || !flow_bb_inside_loop_p (loop, gimple_bb (SSA_NAME_DEF_STMT (ldef))))
     return false;
 
@@ -8486,14 +8487,8 @@ vectorizable_recurr (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
      vectorized the latch definition.  */
   edge le = loop_latch_edge (LOOP_VINFO_LOOP (loop_vinfo));
   gimple *latch_def = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, le));
-  gimple_stmt_iterator gsi2;
-  if (is_a <gphi *> (latch_def))
-    gsi2 = gsi_after_labels (gimple_bb (latch_def));
-  else
-    {
-      gsi2 = gsi_for_stmt (latch_def);
-      gsi_next (&gsi2);
-    }
+  gimple_stmt_iterator gsi2 = gsi_for_stmt (latch_def);
+  gsi_next (&gsi2);
 
   for (unsigned i = 0; i < ncopies; ++i)
     {