diff options
author | Alex Coplan <alex.coplan@arm.com> | 2024-07-25 16:34:05 +0000 |
---|---|---|
committer | Tamar Christina <tamar.christina@arm.com> | 2025-01-10 21:21:07 +0000 |
commit | f4e259b4a66c81c234608056117836e13606e4c8 (patch) | |
tree | 6bbcc47e07d1e6263c8613505f3a91e53b0239a5 /gcc/tree-vect-loop-manip.cc | |
parent | f1c6789ab6c5443ccefab96c74b0e862119d1781 (diff) | |
download | gcc-f4e259b4a66c81c234608056117836e13606e4c8.zip gcc-f4e259b4a66c81c234608056117836e13606e4c8.tar.gz gcc-f4e259b4a66c81c234608056117836e13606e4c8.tar.bz2 |
vect: Ensure we add vector skip guard even when versioning for aliasing [PR118211]
This fixes a latent wrong code issue whereby vect_do_peeling determined
the wrong condition for inserting the vector skip guard. Specifically
in the case where the loop niters are unknown at compile time we used to
check:
!LOOP_REQUIRES_VERSIONING (loop_vinfo)
but LOOP_REQUIRES_VERSIONING is true for loops which we have versioned
for aliasing, and that has nothing to do with prolog peeling. I think
this condition should instead be checking specifically if we aren't
versioning for alignment.
As it stands, when we version for alignment, we don't peel, so the
vector skip guard is indeed redundant in that case.
With the testcase added (reduced from the Fortran frontend) we would
version for aliasing, omit the vector skip guard, and then at runtime we
would peel sufficient iterations for alignment that there wasn't a full
vector iteration left when we entered the vector body, thus overflowing
the output buffer.
gcc/ChangeLog:
PR tree-optimization/118211
PR tree-optimization/116126
* tree-vect-loop-manip.cc (vect_do_peeling): Adjust skip_vector
condition to only omit the edge if we're versioning for
alignment.
gcc/testsuite/ChangeLog:
PR tree-optimization/118211
PR tree-optimization/116126
* gcc.dg/vect/vect-early-break_130.c: New test.
Diffstat (limited to 'gcc/tree-vect-loop-manip.cc')
-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 9a55a56..06ca99e 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -3271,7 +3271,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, bool skip_vector = (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) ? maybe_lt (LOOP_VINFO_INT_NITERS (loop_vinfo), bound_prolog + bound_epilog) - : (!LOOP_REQUIRES_VERSIONING (loop_vinfo) + : (!LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo) || vect_epilogues)); /* Epilog loop must be executed if the number of iterations for epilog |