diff options
author | Tamar Christina <tamar.christina@arm.com> | 2025-07-31 15:29:30 +0100 |
---|---|---|
committer | Tamar Christina <tamar.christina@arm.com> | 2025-07-31 15:29:30 +0100 |
commit | 4a65ae52bacade00989f9840aab5ae11c4ef19f9 (patch) | |
tree | 78eb922c6af3d8af05a1a997f3a9799b07f2b11d | |
parent | 9996036205b5a71e7738f2daa29f4e6f79886a4e (diff) | |
download | gcc-4a65ae52bacade00989f9840aab5ae11c4ef19f9.zip gcc-4a65ae52bacade00989f9840aab5ae11c4ef19f9.tar.gz gcc-4a65ae52bacade00989f9840aab5ae11c4ef19f9.tar.bz2 |
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.
-rw-r--r-- | gcc/tree-vect-loop-manip.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 7fcbc1a..6c1b26a 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)) |