On Mon, 28 Oct 2024, Alex Coplan wrote:

> 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.

OK.

Thanks,
Richard.

> gcc/ChangeLog:
> 
>       * 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:
> 
>       * gcc.dg/vect/vect-early-break_130.c: New test.
> ---
>  .../gcc.dg/vect/vect-early-break_130.c        | 91 +++++++++++++++++++
>  gcc/tree-vect-loop-manip.cc                   |  2 +-
>  2 files changed, 92 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.dg/vect/vect-early-break_130.c
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to