public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [RFC] vect: Fix infinite loop while determining peeling amount
@ 2020-07-22 15:14 Stefan Schulze Frielinghaus
  2020-07-24 15:54 ` Richard Sandiford
  2020-07-27  7:06 ` Richard Biener
  0 siblings, 2 replies; 13+ messages in thread
From: Stefan Schulze Frielinghaus @ 2020-07-22 15:14 UTC (permalink / raw)
  To: gcc-patches

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-07-29  8:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 15:14 [PATCH] [RFC] vect: Fix infinite loop while determining peeling amount Stefan Schulze Frielinghaus
2020-07-24 15:54 ` Richard Sandiford
2020-07-27  7:06 ` Richard Biener
2020-07-27  8:41   ` Richard Sandiford
2020-07-27  9:12     ` Richard Biener
2020-07-27  9:45       ` Richard Sandiford
2020-07-27 10:29         ` Richard Biener
2020-07-27 14:20           ` Stefan Schulze Frielinghaus
2020-07-28  6:55             ` Richard Biener
2020-07-28 15:36               ` Stefan Schulze Frielinghaus
2020-07-29  7:11                 ` Richard Biener
2020-07-29  7:49                   ` Stefan Schulze Frielinghaus
2020-07-29  8:06                     ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).