]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Move updated versioning threshold compute
authorRichard Biener <rguenther@suse.de>
Thu, 31 Oct 2024 08:55:35 +0000 (09:55 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 4 Nov 2024 11:23:04 +0000 (12:23 +0100)
The following moves computing the combined main + epilogue loop
versioning threshold until we figured the epilogues to use rather
than incrementally updating it with the chance to joust candidates
after the fact.

* tree-vect-loop.cc (vect_analyze_loop): Move lowest_th
compute until after epilogue_vinfos is final.

gcc/tree-vect-loop.cc

index df89edac036d5b1509e93bdf84cfe57d9f7444f6..7ed3a56bc68031ab74ffe55cc055b3d54a90337b 100644 (file)
@@ -3691,7 +3691,6 @@ vect_analyze_loop (class loop *loop, gimple *loop_vectorized_call,
     return first_loop_vinfo;
 
   /* Now analyze first_loop_vinfo for epilogue vectorization.  */
-  poly_uint64 lowest_th = LOOP_VINFO_VERSIONING_THRESHOLD (first_loop_vinfo);
 
   /* For epilogues start the analysis from the first mode.  The motivation
      behind starting from the beginning comes from cases where the VECTOR_MODES
@@ -3750,16 +3749,7 @@ vect_analyze_loop (class loop *loop, gimple *loop_vectorized_call,
            }
          /* For now only allow one epilogue loop.  */
          if (first_loop_vinfo->epilogue_vinfos.is_empty ())
-           {
-             first_loop_vinfo->epilogue_vinfos.safe_push (loop_vinfo);
-             poly_uint64 th = LOOP_VINFO_VERSIONING_THRESHOLD (loop_vinfo);
-             gcc_assert (!LOOP_REQUIRES_VERSIONING (loop_vinfo)
-                         || maybe_ne (lowest_th, 0U));
-             /* Keep track of the known smallest versioning
-                threshold.  */
-             if (ordered_p (lowest_th, th))
-               lowest_th = ordered_min (lowest_th, th);
-           }
+           first_loop_vinfo->epilogue_vinfos.safe_push (loop_vinfo);
          else
            {
              delete loop_vinfo;
@@ -3780,6 +3770,17 @@ vect_analyze_loop (class loop *loop, gimple *loop_vectorized_call,
 
   if (!first_loop_vinfo->epilogue_vinfos.is_empty ())
     {
+      poly_uint64 lowest_th
+       = LOOP_VINFO_VERSIONING_THRESHOLD (first_loop_vinfo);
+      for (auto epilog_vinfo : first_loop_vinfo->epilogue_vinfos)
+       {
+         poly_uint64 th = LOOP_VINFO_VERSIONING_THRESHOLD (epilog_vinfo);
+         gcc_assert (!LOOP_REQUIRES_VERSIONING (epilog_vinfo)
+                     || maybe_ne (lowest_th, 0U));
+         /* Keep track of the known smallest versioning threshold.  */
+         if (ordered_p (lowest_th, th))
+           lowest_th = ordered_min (lowest_th, th);
+       }
       LOOP_VINFO_VERSIONING_THRESHOLD (first_loop_vinfo) = lowest_th;
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,