The following moves SLP permute optimization until after we applied
a possible extra unroll factor.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        * tree-vect-loop.cc (vect_analyze_loop_2): Move vect_optimize_slp
        after applying suggested_unroll_factor.
---
 gcc/tree-vect-loop.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 7bb1c6baee8..5ddd11b1a74 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -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,
-- 
2.51.0

Reply via email to