`vect_verify_full_masking_avx512' determines the precision required
for the mask-control induction variable using the maximum number
of scalar iterations. This assumes that the loop has a known
iteration bound, which is not the case for uncounted loops.
Uncounted loops do not use a decrementing induction variable
to generate AVX-512 partial-vector masks. Instead, they use
full masks for subsequent iterations, with the vectorized
early-break conditions controlling loop termination.
Handle uncounted loops separately when determining the required
integer precision. Use the minimum precision needed to
represent the maximum vectorization factor, rather than deriving
it from the scalar iteration count.
Retain the existing precision calculation for counted loops.
gcc/ChangeLog:
* tree-vect-loop.cc (vect_verify_full_masking_avx512): Use
the maximum vectorization factor to determine the required
integer precision for uncounted loops.
---
gcc/tree-vect-loop.cc | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index d6dc75d32b5..c71fbf590c0 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -1139,8 +1139,21 @@ vect_verify_full_masking_avx512 (loop_vec_info
loop_vinfo)
tree iv_type = NULL_TREE;
widest_int iv_limit = vect_iv_limit_for_partial_vectors (loop_vinfo);
unsigned int iv_precision = UINT_MAX;
- if (iv_limit != -1)
- iv_precision = wi::min_precision (iv_limit, UNSIGNED);
+
+ if (LOOP_VINFO_NITERS_UNCOUNTED_P (loop_vinfo))
+ {
+ /* Uncounted loops do not use a decrementing IV. The maximum
+ vectorization factor provides a sufficient precision for
+ selecting a type for the mask controls. */
+ iv_precision
+ = wi::min_precision (vect_max_vf (loop_vinfo), UNSIGNED);
+ }
+ else
+ {
+ widest_int iv_limit = vect_iv_limit_for_partial_vectors (loop_vinfo);
+ if (iv_limit != -1)
+ iv_precision = wi::min_precision (iv_limit, UNSIGNED);
+ }
/* First compute the type for the IV we use to track the remaining
scalar iterations. */
--
2.43.0