From: Tamar Christina Date: Wed, 9 Jul 2025 07:42:02 +0000 (+0100) Subject: middle-end: Use rounding division for ranges for partial vectors [PR120922] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=963d5362c598d48ee7a896e674d2a68c41179785;p=thirdparty%2Fgcc.git middle-end: Use rounding division for ranges for partial vectors [PR120922] 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. --- diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 9c58a6a01d7..2d01a4b0ed1 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -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)),