public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: gcc-patches@gcc.gnu.org, Andreas Krebbel <krebbel@gcc.gnu.org>
Subject: Re: [PATCH v3 3/3] reassoc: Test rank biasing
Date: Tue, 28 Sep 2021 13:28:04 +0200 (CEST)	[thread overview]
Message-ID: <q759p04-qr2-8p63-2q7q-4o71551q1o5@fhfr.qr> (raw)
In-Reply-To: <20210926110936.344019-4-iii@linux.ibm.com>

On Sun, 26 Sep 2021, Ilya Leoshkevich wrote:

> Add both positive and negative tests.

The tests will likely be quite fragile with respect to what is
actually vectorized on which target.  If you move the tests
to gcc.dg/vect/ you could at least do

/* { dg-require-effective-target vect_int } */

do you need to look for the exact GIMPLE IL or is it enough to
verify we are vectorizing the reduction?

Thanks,
Richard.


> gcc/testsuite/ChangeLog:
> 
> 	* gcc.dg/tree-ssa/reassoc-46.c: New test.
> 	* gcc.dg/tree-ssa/reassoc-46.h: Common code for new tests.
> 	* gcc.dg/tree-ssa/reassoc-47.c: New test.
> 	* gcc.dg/tree-ssa/reassoc-48.c: New test.
> 	* gcc.dg/tree-ssa/reassoc-49.c: New test.
> 	* gcc.dg/tree-ssa/reassoc-50.c: New test.
> 	* gcc.dg/tree-ssa/reassoc-51.c: New test.
> ---
>  gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c |  7 +++++
>  gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.h | 33 ++++++++++++++++++++++
>  gcc/testsuite/gcc.dg/tree-ssa/reassoc-47.c |  9 ++++++
>  gcc/testsuite/gcc.dg/tree-ssa/reassoc-48.c |  9 ++++++
>  gcc/testsuite/gcc.dg/tree-ssa/reassoc-49.c | 11 ++++++++
>  gcc/testsuite/gcc.dg/tree-ssa/reassoc-50.c | 10 +++++++
>  gcc/testsuite/gcc.dg/tree-ssa/reassoc-51.c | 11 ++++++++
>  7 files changed, 90 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.h
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/reassoc-47.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/reassoc-48.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/reassoc-49.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/reassoc-50.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/reassoc-51.c
> 
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c
> new file mode 100644
> index 00000000000..97563dd929f
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c
> @@ -0,0 +1,7 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-optimized -ftree-vectorize" } */
> +
> +#include "reassoc-46.h"
> +
> +/* Check that the loop accumulator is added last.  */
> +/* { dg-final { scan-tree-dump-times {(?:vect_)?sum_[\d._]+ = (?:(?:vect_)?_[\d._]+ \+ (?:vect_)?sum_[\d._]+|(?:vect_)?sum_[\d._]+ \+ (?:vect_)?_[\d._]+)} 1 "optimized" } } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.h b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.h
> new file mode 100644
> index 00000000000..e60b490ea0d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.h
> @@ -0,0 +1,33 @@
> +#define M 1024
> +unsigned int arr1[M];
> +unsigned int arr2[M];
> +volatile unsigned int sink;
> +
> +unsigned int
> +test (void)
> +{
> +  unsigned int sum = 0;
> +  for (int i = 0; i < M; i++)
> +    {
> +#ifdef MODIFY
> +      /* Modify the loop accumulator using a chain of operations - this should
> +         not affect its rank biasing.  */
> +      sum |= 1;
> +      sum ^= 2;
> +#endif
> +#ifdef STORE
> +      /* Save the loop accumulator into a global variable - this should not
> +         affect its rank biasing.  */
> +      sink = sum;
> +#endif
> +#ifdef USE
> +      /* Add a tricky use of the loop accumulator - this should prevent its
> +         rank biasing.  */
> +      i = (i + sum) % M;
> +#endif
> +      /* Use addends with different ranks.  */
> +      sum += arr1[i];
> +      sum += arr2[((i ^ 1) + 1) % M];
> +    }
> +  return sum;
> +}
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-47.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-47.c
> new file mode 100644
> index 00000000000..1b0f0fdabe1
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-47.c
> @@ -0,0 +1,9 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-optimized -ftree-vectorize" } */
> +
> +#define MODIFY
> +#include "reassoc-46.h"
> +
> +/* Check that if the loop accumulator is saved into a global variable, it's
> +   still added last.  */
> +/* { dg-final { scan-tree-dump-times {(?:vect_)?sum_[\d._]+ = (?:(?:vect_)?_[\d._]+ \+ (?:vect_)?sum_[\d._]+|(?:vect_)?sum_[\d._]+ \+ (?:vect_)?_[\d._]+)} 1 "optimized" } } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-48.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-48.c
> new file mode 100644
> index 00000000000..13836ebe8e6
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-48.c
> @@ -0,0 +1,9 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-optimized -ftree-vectorize" } */
> +
> +#define STORE
> +#include "reassoc-46.h"
> +
> +/* Check that if the loop accumulator is modified using a chain of operations
> +   other than addition, its new value is still added last.  */
> +/* { dg-final { scan-tree-dump-times {(?:vect_)?sum_[\d._]+ = (?:(?:vect_)?_[\d._]+ \+ (?:vect_)?sum_[\d._]+|(?:vect_)?sum_[\d._]+ \+ (?:vect_)?_[\d._]+)} 1 "optimized" } } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-49.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-49.c
> new file mode 100644
> index 00000000000..c1136a447a2
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-49.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-optimized -ftree-vectorize" } */
> +
> +#define MODIFY
> +#define STORE
> +#include "reassoc-46.h"
> +
> +/* Check that if the loop accumulator is both modified using a chain of
> +   operations other than addition and stored into a global variable, its new
> +   value is still added last.  */
> +/* { dg-final { scan-tree-dump-times {(?:vect_)?sum_[\d._]+ = (?:(?:vect_)?_[\d._]+ \+ (?:vect_)?sum_[\d._]+|(?:vect_)?sum_[\d._]+ \+ (?:vect_)?_[\d._]+)} 1 "optimized" } } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-50.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-50.c
> new file mode 100644
> index 00000000000..e35a4ff1278
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-50.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-optimized -ftree-vectorize" } */
> +
> +#define MODIFY
> +#define USE
> +#include "reassoc-46.h"
> +
> +/* Check that if the loop accumulator has multiple uses inside the loop, it's
> +   not forced to the end of the reassociation chain.  */
> +/* { dg-final { scan-tree-dump-times {(?:vect_)?sum_[\d._]+ = (?:(?:vect_)?_[\d._]+ \+ (?:vect_)?sum_[\d._]+|(?:vect_)?sum_[\d._]+ \+ (?:vect_)?_[\d._]+)} 2 "optimized" } } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-51.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-51.c
> new file mode 100644
> index 00000000000..07175675e24
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-51.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-optimized -ftree-vectorize" } */
> +
> +#define MODIFY
> +#define STORE
> +#define USE
> +#include "reassoc-46.h"
> +
> +/* Check that if the loop accumulator has multiple uses inside the loop, it's
> +   not forced to the end of the reassociation chain.  */
> +/* { dg-final { scan-tree-dump-times {(?:vect_)?sum_[\d._]+ = (?:(?:vect_)?_[\d._]+ \+ (?:vect_)?sum_[\d._]+|(?:vect_)?sum_[\d._]+ \+ (?:vect_)?_[\d._]+)} 2 "optimized" } } */

  reply	other threads:[~2021-09-28 11:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26 11:09 [PATCH v3 0/3] reassoc: Propagate PHI_LOOP_BIAS along single uses Ilya Leoshkevich
2021-09-26 11:09 ` [PATCH v3 1/3] reassoc: Do not bias loop-carried PHIs early Ilya Leoshkevich
2021-09-28 11:21   ` Richard Biener
2021-09-26 11:09 ` [PATCH v3 2/3] reassoc: Propagate PHI_LOOP_BIAS along single uses Ilya Leoshkevich
2021-09-28 11:24   ` Richard Biener
2021-09-26 11:09 ` [PATCH v3 3/3] reassoc: Test rank biasing Ilya Leoshkevich
2021-09-28 11:28   ` Richard Biener [this message]
2021-09-28 11:46     ` Ilya Leoshkevich
2021-09-28 12:38       ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=q759p04-qr2-8p63-2q7q-4o71551q1o5@fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iii@linux.ibm.com \
    --cc=krebbel@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).