]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix vect_need_peeling_or_partial_vectors_p wrt peeling for gaps
authorRichard Biener <rguenther@suse.de>
Fri, 5 Dec 2025 11:25:09 +0000 (12:25 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 5 Dec 2025 12:29:41 +0000 (13:29 +0100)
The code assuming that peeling for gaps can be elided by means of
knowing niters and prologue peeling is wrong.  Peeling for gaps
means we need an epilog.

* tree-vect-loop.cc (vect_need_peeling_or_partial_vectors_p):
When peeling for gaps we always need an epilog.

gcc/tree-vect-loop.cc

index 82121ca21ba4c27e1851e2f112bbd3a002fa36ed..53923c07e181cc330b8c4ac383cb02b3647d3963 100644 (file)
@@ -942,6 +942,9 @@ vect_need_peeling_or_partial_vectors_p (loop_vec_info loop_vinfo)
 {
   unsigned HOST_WIDE_INT const_vf;
 
+  if (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))
+    return true;
+
   loop_vec_info main_loop_vinfo
     = (LOOP_VINFO_EPILOGUE_P (loop_vinfo)
        ? LOOP_VINFO_MAIN_LOOP_INFO (loop_vinfo) : loop_vinfo);
@@ -952,14 +955,11 @@ vect_need_peeling_or_partial_vectors_p (loop_vec_info loop_vinfo)
         peeled for reasons other than niters.  */
       unsigned int peel_niter
        = LOOP_VINFO_PEELING_FOR_ALIGNMENT (main_loop_vinfo);
-      if (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))
-       peel_niter += 1;
       return !multiple_p (LOOP_VINFO_INT_NITERS (loop_vinfo) - peel_niter,
                          LOOP_VINFO_VECT_FACTOR (loop_vinfo));
     }
 
   if (!LOOP_VINFO_PEELING_FOR_ALIGNMENT (main_loop_vinfo)
-      && !LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)
       && LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant (&const_vf))
     {
       /* When the number of iterations is a multiple of the vectorization