]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Move SLP permute optimization until after VF is final
authorRichard Biener <rguenther@suse.de>
Thu, 23 Oct 2025 09:05:45 +0000 (11:05 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 23 Oct 2025 10:57:21 +0000 (12:57 +0200)
The following moves SLP permute optimization until after we applied
a possible extra unroll factor.

* tree-vect-loop.cc (vect_analyze_loop_2): Move vect_optimize_slp
after applying suggested_unroll_factor.

gcc/tree-vect-loop.cc

index bc01e12f05bc3cebe5e10535355e5ef1d3b4bd56..d44a77d85c3f68e1a08f04de6bc9aec6e5e6edcf 100644 (file)
@@ -2253,12 +2253,6 @@ start_over:
       dump_printf (MSG_NOTE, "\n");
     }
 
-  /* Optimize the SLP graph with the vectorization factor fixed.  */
-  vect_optimize_slp (loop_vinfo);
-
-  /* Gather the loads reachable from the SLP graph entries.  */
-  vect_gather_slp_loads (loop_vinfo);
-
   /* We don't expect to have to roll back to anything other than an empty
      set of rgroups.  */
   gcc_assert (LOOP_VINFO_MASKS (loop_vinfo).is_empty ());
@@ -2273,6 +2267,12 @@ start_over:
   poly_uint64 vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
   gcc_assert (known_ne (vectorization_factor, 0U));
 
+  /* Optimize the SLP graph with the vectorization factor fixed.  */
+  vect_optimize_slp (loop_vinfo);
+
+  /* Gather the loads reachable from the SLP graph entries.  */
+  vect_gather_slp_loads (loop_vinfo);
+
   if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) && dump_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,