public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] testsuite: add the case to cover vectorization of A[(i+x)*stride] [PR114322]
@ 2024-03-20  7:55 Hao Liu OS
  2024-03-20  8:21 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Hao Liu OS @ 2024-03-20  7:55 UTC (permalink / raw)
  To: Richard Biener, GCC-patches@gcc.gnu.org

Hi Richard,

As mentioned in the comments of PR114322 (which has been fixed by PR114151
r14-9540-ge0e9499a), this patch is to cover the case.

Bootstrapped and regression tested on aarch64-linux-gnu, OK for trunk?

gcc/testsuite/ChangeLog:

	PR tree-optimization/114322
	* gcc.dg/vect/pr114322.c: New testcase.

diff --git a/gcc/testsuite/gcc.dg/vect/pr114322.c b/gcc/testsuite/gcc.dg/vect/pr114322.c
new file mode 100644
index 00000000000..7c3a4ffe260
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr114322.c
@@ -0,0 +1,18 @@
+/* PR tree-optimization/114322 */
+/* { dg-do compile } */
+
+int
+foo (short *A, int x, int stride)
+{
+  int sum = 0;
+
+  if (stride > 1)
+    {
+      for (int i = 0; i < 1024; ++i)
+        sum += A[(i + x) * stride];
+    }
+
+  return sum;
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target aarch64*-*-* } } } */
-- 
2.34.1


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

* Re: [PATCH] testsuite: add the case to cover vectorization of A[(i+x)*stride] [PR114322]
  2024-03-20  7:55 [PATCH] testsuite: add the case to cover vectorization of A[(i+x)*stride] [PR114322] Hao Liu OS
@ 2024-03-20  8:21 ` Richard Biener
  2024-03-20  9:43   ` Hao Liu OS
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2024-03-20  8:21 UTC (permalink / raw)
  To: Hao Liu OS; +Cc: GCC-patches@gcc.gnu.org

On Wed, 20 Mar 2024, Hao Liu OS wrote:

> Hi Richard,
> 
> As mentioned in the comments of PR114322 (which has been fixed by PR114151
> r14-9540-ge0e9499a), this patch is to cover the case.
> 
> Bootstrapped and regression tested on aarch64-linux-gnu, OK for trunk?
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR tree-optimization/114322
> 	* gcc.dg/vect/pr114322.c: New testcase.
> 
> diff --git a/gcc/testsuite/gcc.dg/vect/pr114322.c b/gcc/testsuite/gcc.dg/vect/pr114322.c
> new file mode 100644
> index 00000000000..7c3a4ffe260
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/vect/pr114322.c
> @@ -0,0 +1,18 @@
> +/* PR tree-optimization/114322 */
> +/* { dg-do compile } */
> +
> +int
> +foo (short *A, int x, int stride)
> +{
> +  int sum = 0;
> +
> +  if (stride > 1)
> +    {
> +      for (int i = 0; i < 1024; ++i)
> +        sum += A[(i + x) * stride];
> +    }
> +
> +  return sum;
> +}
> +
> +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target aarch64*-*-* } } } */

I don't like the target selector very much - if you make 'A'
a 'int *', the strided access should be the important part,
vect_int should match the requirements - the strided access should
end up with VMAT_ELEMENTWISE at worst (possibly gather on aarch64?),
and VMAT_ELEMENTWISE doesn't need any alignment.

So - OK with using { target vect_int } instead.

Richard.

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

* Re: [PATCH] testsuite: add the case to cover vectorization of A[(i+x)*stride] [PR114322]
  2024-03-20  8:21 ` Richard Biener
@ 2024-03-20  9:43   ` Hao Liu OS
  0 siblings, 0 replies; 3+ messages in thread
From: Hao Liu OS @ 2024-03-20  9:43 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC-patches@gcc.gnu.org

> So - OK with using { target vect_int } instead.

Sure, it's much better to be target independent.

Refactored and committed in r14-9569-g4c276896

Thanks,
- Hao

________________________________________
From: Richard Biener <rguenther@suse.de>
Sent: Wednesday, March 20, 2024 16:21
To: Hao Liu OS
Cc: GCC-patches@gcc.gnu.org
Subject: Re: [PATCH] testsuite: add the case to cover vectorization of A[(i+x)*stride] [PR114322]

On Wed, 20 Mar 2024, Hao Liu OS wrote:

> Hi Richard,
>
> As mentioned in the comments of PR114322 (which has been fixed by PR114151
> r14-9540-ge0e9499a), this patch is to cover the case.
>
> Bootstrapped and regression tested on aarch64-linux-gnu, OK for trunk?
>
> gcc/testsuite/ChangeLog:
>
>       PR tree-optimization/114322
>       * gcc.dg/vect/pr114322.c: New testcase.
>
> diff --git a/gcc/testsuite/gcc.dg/vect/pr114322.c b/gcc/testsuite/gcc.dg/vect/pr114322.c
> new file mode 100644
> index 00000000000..7c3a4ffe260
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/vect/pr114322.c
> @@ -0,0 +1,18 @@
> +/* PR tree-optimization/114322 */
> +/* { dg-do compile } */
> +
> +int
> +foo (short *A, int x, int stride)
> +{
> +  int sum = 0;
> +
> +  if (stride > 1)
> +    {
> +      for (int i = 0; i < 1024; ++i)
> +        sum += A[(i + x) * stride];
> +    }
> +
> +  return sum;
> +}
> +
> +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target aarch64*-*-* } } } */

I don't like the target selector very much - if you make 'A'
a 'int *', the strided access should be the important part,
vect_int should match the requirements - the strided access should
end up with VMAT_ELEMENTWISE at worst (possibly gather on aarch64?),
and VMAT_ELEMENTWISE doesn't need any alignment.

So - OK with using { target vect_int } instead.

Richard.

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

end of thread, other threads:[~2024-03-20  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-20  7:55 [PATCH] testsuite: add the case to cover vectorization of A[(i+x)*stride] [PR114322] Hao Liu OS
2024-03-20  8:21 ` Richard Biener
2024-03-20  9:43   ` Hao Liu OS

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