public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-6582] slp: fix is_linear_load_p to prevent multiple answers
@ 2021-01-11  9:59 Tamar Christina
  0 siblings, 0 replies; only message in thread
From: Tamar Christina @ 2021-01-11  9:59 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:39666d2b8858361b4921fe0ae87bba90a62d9b9a

commit r11-6582-g39666d2b8858361b4921fe0ae87bba90a62d9b9a
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Mon Jan 11 09:56:44 2021 +0000

    slp: fix is_linear_load_p to prevent multiple answers
    
    This fixes an issue where is_linear_load_p could return the incorrect
    permutation kind because it is singe pass.
    
    This arranges the candidates in such a way that there won't be any ambiguity so
    that the function can still be linear but give correct values.
    
    gcc/ChangeLog:
    
            * tree-vect-slp-patterns.c (is_linear_load_p): Fix ambiguity.

Diff:
---
 gcc/tree-vect-slp-patterns.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c
index 9b8ba415b15..e30cea110f6 100644
--- a/gcc/tree-vect-slp-patterns.c
+++ b/gcc/tree-vect-slp-patterns.c
@@ -140,32 +140,32 @@ is_linear_load_p (load_permutation_t loads)
 
   unsigned load, i;
   complex_perm_kinds_t candidates[4]
-    = { PERM_EVENODD
-      , PERM_ODDEVEN
-      , PERM_ODDODD
+    = { PERM_ODDODD
       , PERM_EVENEVEN
+      , PERM_EVENODD
+      , PERM_ODDEVEN
       };
 
   int valid_patterns = 4;
-  FOR_EACH_VEC_ELT_FROM (loads, i, load, 1)
+  FOR_EACH_VEC_ELT (loads, i, load)
     {
-      if (candidates[0] != PERM_UNKNOWN && load != i)
+      if (candidates[0] != PERM_UNKNOWN && load != 1)
 	{
 	  candidates[0] = PERM_UNKNOWN;
 	  valid_patterns--;
 	}
-      if (candidates[1] != PERM_UNKNOWN
-	  && load != (i % 2 == 0 ? i + 1 : i - 1))
+      if (candidates[1] != PERM_UNKNOWN && load != 0)
 	{
 	  candidates[1] = PERM_UNKNOWN;
 	  valid_patterns--;
 	}
-      if (candidates[2] != PERM_UNKNOWN && load != 1)
+      if (candidates[2] != PERM_UNKNOWN && load != i)
 	{
 	  candidates[2] = PERM_UNKNOWN;
 	  valid_patterns--;
 	}
-      if (candidates[3] != PERM_UNKNOWN && load != 0)
+      if (candidates[3] != PERM_UNKNOWN
+	  && load != (i % 2 == 0 ? i + 1 : i - 1))
 	{
 	  candidates[3] = PERM_UNKNOWN;
 	  valid_patterns--;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-11  9:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11  9:59 [gcc r11-6582] slp: fix is_linear_load_p to prevent multiple answers Tamar Christina

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