public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] test: Fix bb-slp-33.c for RVV
@ 2023-11-07  8:47 Juzhe-Zhong
  2023-11-07 13:48 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Juzhe-Zhong @ 2023-11-07  8:47 UTC (permalink / raw)
  To: gcc-patches; +Cc: rguenther, jeffreyalaw, Juzhe-Zhong

As https://godbolt.org/z/hPsqahEa5 shows.
RVV failed dump check since "vectorizing stmts using SLP" shows 3 times instead of 2.

The root cause is this code in main:

  if (a[0] != 1
      || a[1] != 2
      || a[2] != 3
      || a[3] != 4
      || a[4] != 7
      || a[5] != 0
      || a[6] != 0
      || a[7] != 0
      || a[8] != 0)
    abort ();

is vectorized. So add -fno-tree-vectorize avoid the confusing check.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/bb-slp-33.c: Add -fno-tree-vectorize to main.

---
 gcc/testsuite/gcc.dg/vect/bb-slp-33.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-33.c b/gcc/testsuite/gcc.dg/vect/bb-slp-33.c
index bbb13ef798e..f44cbdcfbcf 100644
--- a/gcc/testsuite/gcc.dg/vect/bb-slp-33.c
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-33.c
@@ -17,7 +17,8 @@ test(int *__restrict__ a, int *__restrict__ b)
   a[8] = 0;
 }
 
-int main()
+int __attribute__((optimize(("-fno-tree-vectorize"))))
+main()
 {
   int a[9];
   int b[4];
-- 
2.36.3


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

* Re: [PATCH] test: Fix bb-slp-33.c for RVV
  2023-11-07  8:47 [PATCH] test: Fix bb-slp-33.c for RVV Juzhe-Zhong
@ 2023-11-07 13:48 ` Richard Biener
  2023-11-07 15:19   ` 钟居哲
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2023-11-07 13:48 UTC (permalink / raw)
  To: Juzhe-Zhong; +Cc: gcc-patches, jeffreyalaw

On Tue, 7 Nov 2023, Juzhe-Zhong wrote:

> As https://godbolt.org/z/hPsqahEa5 shows.
> RVV failed dump check since "vectorizing stmts using SLP" shows 3 times instead of 2.
> 
> The root cause is this code in main:
> 
>   if (a[0] != 1
>       || a[1] != 2
>       || a[2] != 3
>       || a[3] != 4
>       || a[4] != 7
>       || a[5] != 0
>       || a[6] != 0
>       || a[7] != 0
>       || a[8] != 0)
>     abort ();
> 
> is vectorized. So add -fno-tree-vectorize avoid the confusing check.

Uh, please don't add optimize attributes.  If you see this vectorized
(as reduction?) then please instead rewrite the condition as

 if (a[0] != 1)
   abort ();
 __asm__ volatile ("");
 if (a[1] != 2)
   abort ();
...

> gcc/testsuite/ChangeLog:
> 
> 	* gcc.dg/vect/bb-slp-33.c: Add -fno-tree-vectorize to main.
> 
> ---
>  gcc/testsuite/gcc.dg/vect/bb-slp-33.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-33.c b/gcc/testsuite/gcc.dg/vect/bb-slp-33.c
> index bbb13ef798e..f44cbdcfbcf 100644
> --- a/gcc/testsuite/gcc.dg/vect/bb-slp-33.c
> +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-33.c
> @@ -17,7 +17,8 @@ test(int *__restrict__ a, int *__restrict__ b)
>    a[8] = 0;
>  }
>  
> -int main()
> +int __attribute__((optimize(("-fno-tree-vectorize"))))
> +main()
>  {
>    int a[9];
>    int b[4];
> 

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

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

* Re: Re: [PATCH] test: Fix bb-slp-33.c for RVV
  2023-11-07 13:48 ` Richard Biener
@ 2023-11-07 15:19   ` 钟居哲
  0 siblings, 0 replies; 3+ messages in thread
From: 钟居哲 @ 2023-11-07 15:19 UTC (permalink / raw)
  To: rguenther; +Cc: gcc-patches, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 1904 bytes --]

Thanks Richi.

Adapt condtion in V2:
https://gcc.gnu.org/pipermail/gcc-patches/2023-November/635589.html 




juzhe.zhong@rivai.ai
 
From: Richard Biener
Date: 2023-11-07 21:48
To: Juzhe-Zhong
CC: gcc-patches; jeffreyalaw
Subject: Re: [PATCH] test: Fix bb-slp-33.c for RVV
On Tue, 7 Nov 2023, Juzhe-Zhong wrote:
 
> As https://godbolt.org/z/hPsqahEa5 shows.
> RVV failed dump check since "vectorizing stmts using SLP" shows 3 times instead of 2.
> 
> The root cause is this code in main:
> 
>   if (a[0] != 1
>       || a[1] != 2
>       || a[2] != 3
>       || a[3] != 4
>       || a[4] != 7
>       || a[5] != 0
>       || a[6] != 0
>       || a[7] != 0
>       || a[8] != 0)
>     abort ();
> 
> is vectorized. So add -fno-tree-vectorize avoid the confusing check.
 
Uh, please don't add optimize attributes.  If you see this vectorized
(as reduction?) then please instead rewrite the condition as
 
if (a[0] != 1)
   abort ();
__asm__ volatile ("");
if (a[1] != 2)
   abort ();
...
 
> gcc/testsuite/ChangeLog:
> 
> * gcc.dg/vect/bb-slp-33.c: Add -fno-tree-vectorize to main.
> 
> ---
>  gcc/testsuite/gcc.dg/vect/bb-slp-33.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-33.c b/gcc/testsuite/gcc.dg/vect/bb-slp-33.c
> index bbb13ef798e..f44cbdcfbcf 100644
> --- a/gcc/testsuite/gcc.dg/vect/bb-slp-33.c
> +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-33.c
> @@ -17,7 +17,8 @@ test(int *__restrict__ a, int *__restrict__ b)
>    a[8] = 0;
>  }
>  
> -int main()
> +int __attribute__((optimize(("-fno-tree-vectorize"))))
> +main()
>  {
>    int a[9];
>    int b[4];
> 
 
-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
 

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

end of thread, other threads:[~2023-11-07 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-07  8:47 [PATCH] test: Fix bb-slp-33.c for RVV Juzhe-Zhong
2023-11-07 13:48 ` Richard Biener
2023-11-07 15:19   ` 钟居哲

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