This is a follow up to commit 5c9669a0e6c respectively discussion https://gcc.gnu.org/pipermail/gcc-patches/2020-June/549132.html
In case that an alignment constraint is less than the size of a corresponding scalar type, ensure that we advance at least by one iteration. For example, on s390x we have for a long double an alignment constraint of 8 bytes whereas the size is 16 bytes. Therefore, TARGET_ALIGN / DR_SIZE equals zero resulting in an infinite loop which can be reproduced by the following MWE: extern long double *a; extern double *b; void fun(void) { for (int i = 0; i < 42; i++) a[i] = b[i]; } Increasing the number of peelings in each iteration at least by one fixes the issue for me. Any comments? Bootstrapped and regtested on s390x. gcc/ChangeLog: * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Ensure that loop variable npeel_tmp advances in each iteration. --- gcc/tree-vect-data-refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index e35a215e042..a78ae61d1b0 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -1779,7 +1779,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) { vect_peeling_hash_insert (&peeling_htab, loop_vinfo, dr_info, npeel_tmp); - npeel_tmp += target_align / dr_size; + npeel_tmp += MAX (1, target_align / dr_size); } one_misalignment_known = true; -- 2.25.3