public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] aarch64: Fix undefined code in vect_ctz_1.c
@ 2024-02-02 21:24 Andrew Pinski
  2024-02-15 18:01 ` Richard Sandiford
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2024-02-02 21:24 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

The testcase gcc.target/aarch64/vect_ctz_1.c fails execution when running
with -march=armv9-a due to the testcase calls __builtin_ctz with a value of 0.
The testcase should not depend on undefined behavior of __builtin_ctz. So this
changes it to use the g form with the 2nd argument of 32. Now the execution part
of the testcase work. It still has a scan-assembler failure which should be fixed
seperately.

OK? Tested on aarch64-linux-gnu.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/vect_ctz_1.c (TEST): Use g form of the builtin and pass 32
	as the value expected at 0.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
 gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c b/gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c
index c4eaf5b3a91..5fcf1e31ab2 100644
--- a/gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c
@@ -9,7 +9,7 @@ count_tz_##name (unsigned *__restrict a, int *__restrict b) \
 { \
   int i; \
   for (i = 0; i < count; i++) \
-    b[i] = __builtin_##subname (a[i]); \
+    b[i] = __builtin_##subname##g (a[i], 32); \
 }
 
 #define CHECK(name, count, input, output) \
-- 
2.43.0


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

* Re: [PATCH] aarch64: Fix undefined code in vect_ctz_1.c
  2024-02-02 21:24 [PATCH] aarch64: Fix undefined code in vect_ctz_1.c Andrew Pinski
@ 2024-02-15 18:01 ` Richard Sandiford
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2024-02-15 18:01 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

Andrew Pinski <quic_apinski@quicinc.com> writes:
> The testcase gcc.target/aarch64/vect_ctz_1.c fails execution when running
> with -march=armv9-a due to the testcase calls __builtin_ctz with a value of 0.
> The testcase should not depend on undefined behavior of __builtin_ctz. So this
> changes it to use the g form with the 2nd argument of 32. Now the execution part
> of the testcase work. It still has a scan-assembler failure which should be fixed
> seperately.
>
> OK? Tested on aarch64-linux-gnu.
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.target/aarch64/vect_ctz_1.c (TEST): Use g form of the builtin and pass 32
> 	as the value expected at 0.

OK, but it looks like vect-clz.c could use the same fix.

I think we have enough coverage elsewhere that we still use CLZ for the
"normal" builtins (e.g. sve/clz_1.c).

Richard

> Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
> ---
>  gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c b/gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c
> index c4eaf5b3a91..5fcf1e31ab2 100644
> --- a/gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c
> +++ b/gcc/testsuite/gcc.target/aarch64/vect_ctz_1.c
> @@ -9,7 +9,7 @@ count_tz_##name (unsigned *__restrict a, int *__restrict b) \
>  { \
>    int i; \
>    for (i = 0; i < count; i++) \
> -    b[i] = __builtin_##subname (a[i]); \
> +    b[i] = __builtin_##subname##g (a[i], 32); \
>  }
>  
>  #define CHECK(name, count, input, output) \

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

end of thread, other threads:[~2024-02-15 18:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02 21:24 [PATCH] aarch64: Fix undefined code in vect_ctz_1.c Andrew Pinski
2024-02-15 18:01 ` Richard Sandiford

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