]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: Use rounding division for ranges for partial vectors [PR120922]
authorTamar Christina <tamar.christina@arm.com>
Wed, 9 Jul 2025 07:42:02 +0000 (08:42 +0100)
committerTamar Christina <tamar.christina@arm.com>
Wed, 9 Jul 2025 07:42:02 +0000 (08:42 +0100)
This patch adds support for niters ranges for partial
vector loops.

Due to the last iteration being partial the bounds should
be at least 1 but niters // vf as the max.

gcc/ChangeLog:

PR tree-optimization/120922
* tree-vect-loop-manip.cc (vect_gen_vector_loop_niters): Support range
for partial vectors.

gcc/tree-vect-loop-manip.cc

index 9c58a6a01d7c9c3d97a2f8595b1ea6cff2d653f6..2d01a4b0ed1c8431510ad5e6e2175dbe89371618 100644 (file)
@@ -2857,11 +2857,21 @@ vect_gen_vector_loop_niters (loop_vec_info loop_vinfo, tree niters,
         we set range information to make niters analyzer's life easier.
         Note the number of latch iteration value can be TYPE_MAX_VALUE so
         we have to represent the vector niter TYPE_MAX_VALUE + 1 / vf.  */
-      if (stmts != NULL
-         && const_vf > 0
-         && !LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo))
+      if (stmts != NULL && const_vf > 0)
        {
-         if (niters_no_overflow)
+         if (niters_no_overflow
+             && LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo))
+           {
+             int_range<1> vr (type,
+                              wi::one (TYPE_PRECISION (type)),
+                              wi::div_ceil (wi::max_value
+                                                       (TYPE_PRECISION (type),
+                                                        TYPE_SIGN (type)),
+                                            const_vf,
+                                            TYPE_SIGN (type)));
+             set_range_info (niters_vector, vr);
+           }
+         else if (niters_no_overflow)
            {
              int_range<1> vr (type,
                               wi::one (TYPE_PRECISION (type)),