https://gcc.gnu.org/g:4a65ae52bacade00989f9840aab5ae11c4ef19f9
commit r16-2685-g4a65ae52bacade00989f9840aab5ae11c4ef19f9 Author: Tamar Christina <tamar.christ...@arm.com> Date: Thu Jul 31 15:29:30 2025 +0100 vect: Don't set bogus bounds on epilogues [PR120805] The testcases in the PR are failing due to the code trying to set a vector range on an epilogue. However on epilogues the range doesn't make sense. In particular we are setting ranged to help niters analysis. But the epilogue doesn't iterate. Secondly the bounds variable hasn't been adjusted to vector iterations: In the epilogue this is calculated as <bb 13> [local count: 81467476]: # i_127 = PHI <tmp.7_131(10), 0(5)> # _132 = PHI <_133(10), 0(5)> _181 = (unsigned int) n_41(D); bnd.31_180 = _181 - _132; where _133 = niters_vector_mult_vf.6_130; but _132 is a phi node, and if coming from the vector loop skip edge _181 will be <1, VF>. But this is a range VRP or Ranger can easily report due to the guard on the skip_vector loop. Previously, non-const VF would skip this code entirely due to the .is_constant() check. Non-partial vector loop would also skip it because the bounds would fold to a constant. so it doesn't enter the !gimple_value check. When support for partial vector ranges was added, this accidentally enabled ranges on partial vector epilogues. This patch now makes it explicit that ranges shouldn't be set for epilogues, as they don't seem to be useful anyway. gcc/ChangeLog: PR tree-optimization/120805 * tree-vect-loop-manip.cc (vect_gen_vector_loop_niters): Skip setting bounds on epilogues. Diff: --- gcc/tree-vect-loop-manip.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 7fcbc1ad2eb8..6c1b26adda3b 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -2857,7 +2857,7 @@ 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) + if (stmts != NULL && const_vf > 0 && !LOOP_VINFO_EPILOGUE_P (loop_vinfo)) { if (niters_no_overflow && LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo))