public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/5] testsuite: Fix vect/vect-sdiv-pow2-1.c
@ 2020-11-17 11:23 Richard Sandiford
  2020-11-17 12:57 ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Sandiford @ 2020-11-17 11:23 UTC (permalink / raw)
  To: gcc-patches

We're now able to vectorise the set-up loop:

      int p = power2 (fns[i].po2);
      for (int j = 0; j < N; j++)
        a[j] = ((p << 4) * j) / (N - 1) - (p << 5);

Rather than adjust the expected output for that, it seemed better
to disable optimisation for the testing code.

Tested on aarch64-linux-gnu (with and without SVE), arm-linux-gnueabihf
and x86_64-linux-gnu.  OK to install?

Richard


gcc/testsuite/
	* gcc.dg/vect/vect-sdiv-pow2-1.c (main): Disable optimization.
---
 gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
index be70bc6c47e..bf387133d01 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
@@ -53,7 +53,7 @@ power2 (int x)
 
 #define N 50
 
-int
+int __attribute__ ((optimize (0)))
 main (void)
 {
   int a[N], b[N], c[N];

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

* Re: [PATCH 1/5] testsuite: Fix vect/vect-sdiv-pow2-1.c
  2020-11-17 11:23 [PATCH 1/5] testsuite: Fix vect/vect-sdiv-pow2-1.c Richard Sandiford
@ 2020-11-17 12:57 ` Richard Biener
  2020-11-17 13:02   ` Richard Sandiford
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2020-11-17 12:57 UTC (permalink / raw)
  To: Richard Sandiford, GCC Patches

On Tue, Nov 17, 2020 at 12:24 PM Richard Sandiford via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> We're now able to vectorise the set-up loop:
>
>       int p = power2 (fns[i].po2);
>       for (int j = 0; j < N; j++)
>         a[j] = ((p << 4) * j) / (N - 1) - (p << 5);
>
> Rather than adjust the expected output for that, it seemed better
> to disable optimisation for the testing code.
>
> Tested on aarch64-linux-gnu (with and without SVE), arm-linux-gnueabihf
> and x86_64-linux-gnu.  OK to install?

In other places we just add a asm ("" : : : "memory") to the loop body, can you
do it like htat?

Thanks,
RIchard.

> Richard
>
>
> gcc/testsuite/
>         * gcc.dg/vect/vect-sdiv-pow2-1.c (main): Disable optimization.
> ---
>  gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
> index be70bc6c47e..bf387133d01 100644
> --- a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
> +++ b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
> @@ -53,7 +53,7 @@ power2 (int x)
>
>  #define N 50
>
> -int
> +int __attribute__ ((optimize (0)))
>  main (void)
>  {
>    int a[N], b[N], c[N];

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

* Re: [PATCH 1/5] testsuite: Fix vect/vect-sdiv-pow2-1.c
  2020-11-17 12:57 ` Richard Biener
@ 2020-11-17 13:02   ` Richard Sandiford
  2020-11-18  7:57     ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Sandiford @ 2020-11-17 13:02 UTC (permalink / raw)
  To: Richard Biener via Gcc-patches

Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> On Tue, Nov 17, 2020 at 12:24 PM Richard Sandiford via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> We're now able to vectorise the set-up loop:
>>
>>       int p = power2 (fns[i].po2);
>>       for (int j = 0; j < N; j++)
>>         a[j] = ((p << 4) * j) / (N - 1) - (p << 5);
>>
>> Rather than adjust the expected output for that, it seemed better
>> to disable optimisation for the testing code.
>>
>> Tested on aarch64-linux-gnu (with and without SVE), arm-linux-gnueabihf
>> and x86_64-linux-gnu.  OK to install?
>
> In other places we just add a asm ("" : : : "memory") to the loop body, can you
> do it like htat?

I wondered about that, but I don't think it's reliable long-term.
We could (perhaps rightly) decide that it's a win to vectorise the
rhs of a[j] even if the asm prevents us from doing a vector store.

Thanks,
Richard

>
> Thanks,
> RIchard.
>
>> Richard
>>
>>
>> gcc/testsuite/
>>         * gcc.dg/vect/vect-sdiv-pow2-1.c (main): Disable optimization.
>> ---
>>  gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
>> index be70bc6c47e..bf387133d01 100644
>> --- a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
>> +++ b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
>> @@ -53,7 +53,7 @@ power2 (int x)
>>
>>  #define N 50
>>
>> -int
>> +int __attribute__ ((optimize (0)))
>>  main (void)
>>  {
>>    int a[N], b[N], c[N];

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

* Re: [PATCH 1/5] testsuite: Fix vect/vect-sdiv-pow2-1.c
  2020-11-17 13:02   ` Richard Sandiford
@ 2020-11-18  7:57     ` Richard Biener
  2020-11-18 18:44       ` Richard Sandiford
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2020-11-18  7:57 UTC (permalink / raw)
  To: Richard Biener via Gcc-patches, Richard Biener, Richard Sandiford

On Tue, Nov 17, 2020 at 2:02 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> > On Tue, Nov 17, 2020 at 12:24 PM Richard Sandiford via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> >>
> >> We're now able to vectorise the set-up loop:
> >>
> >>       int p = power2 (fns[i].po2);
> >>       for (int j = 0; j < N; j++)
> >>         a[j] = ((p << 4) * j) / (N - 1) - (p << 5);
> >>
> >> Rather than adjust the expected output for that, it seemed better
> >> to disable optimisation for the testing code.
> >>
> >> Tested on aarch64-linux-gnu (with and without SVE), arm-linux-gnueabihf
> >> and x86_64-linux-gnu.  OK to install?
> >
> > In other places we just add a asm ("" : : : "memory") to the loop body, can you
> > do it like htat?
>
> I wondered about that, but I don't think it's reliable long-term.
> We could (perhaps rightly) decide that it's a win to vectorise the
> rhs of a[j] even if the asm prevents us from doing a vector store.

But this is about dump-scanning and I'd rather avoid optimize attributes
since that removes coverage gained by people running the testsuite
with random set of options.

We do have #pragma no_vector support in the middle-end just not
yet in the C FE parser (see where it builds ANNOTATE_EXPRs,
add support for the annot_expr_no_vector_kind).  If you want a
future-proof reliable way to disable vectorizing a loop, that is.

Richard.

> Thanks,
> Richard
>
> >
> > Thanks,
> > RIchard.
> >
> >> Richard
> >>
> >>
> >> gcc/testsuite/
> >>         * gcc.dg/vect/vect-sdiv-pow2-1.c (main): Disable optimization.
> >> ---
> >>  gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
> >> index be70bc6c47e..bf387133d01 100644
> >> --- a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
> >> +++ b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
> >> @@ -53,7 +53,7 @@ power2 (int x)
> >>
> >>  #define N 50
> >>
> >> -int
> >> +int __attribute__ ((optimize (0)))
> >>  main (void)
> >>  {
> >>    int a[N], b[N], c[N];

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

* Re: [PATCH 1/5] testsuite: Fix vect/vect-sdiv-pow2-1.c
  2020-11-18  7:57     ` Richard Biener
@ 2020-11-18 18:44       ` Richard Sandiford
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Sandiford @ 2020-11-18 18:44 UTC (permalink / raw)
  To: Richard Biener; +Cc: Richard Biener via Gcc-patches

Richard Biener <richard.guenther@gmail.com> writes:
> On Tue, Nov 17, 2020 at 2:02 PM Richard Sandiford
> <richard.sandiford@arm.com> wrote:
>>
>> Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>> > On Tue, Nov 17, 2020 at 12:24 PM Richard Sandiford via Gcc-patches
>> > <gcc-patches@gcc.gnu.org> wrote:
>> >>
>> >> We're now able to vectorise the set-up loop:
>> >>
>> >>       int p = power2 (fns[i].po2);
>> >>       for (int j = 0; j < N; j++)
>> >>         a[j] = ((p << 4) * j) / (N - 1) - (p << 5);
>> >>
>> >> Rather than adjust the expected output for that, it seemed better
>> >> to disable optimisation for the testing code.
>> >>
>> >> Tested on aarch64-linux-gnu (with and without SVE), arm-linux-gnueabihf
>> >> and x86_64-linux-gnu.  OK to install?
>> >
>> > In other places we just add a asm ("" : : : "memory") to the loop body, can you
>> > do it like htat?
>>
>> I wondered about that, but I don't think it's reliable long-term.
>> We could (perhaps rightly) decide that it's a win to vectorise the
>> rhs of a[j] even if the asm prevents us from doing a vector store.
>
> But this is about dump-scanning and I'd rather avoid optimize attributes
> since that removes coverage gained by people running the testsuite
> with random set of options.

Yeah, but I'd argue that getting optimisation coverage of the validity
checking isn't really a good thing, since it just increases the chances
that the validity code will be misoptimised in the same way as the code
that it's testing.  Can see it cuts both ways though.

> We do have #pragma no_vector support in the middle-end just not
> yet in the C FE parser (see where it builds ANNOTATE_EXPRs,
> add support for the annot_expr_no_vector_kind).  If you want a
> future-proof reliable way to disable vectorizing a loop, that is.

OK, I went for your original suggestion of using an asm.

Thanks,
Richard


gcc/testsuite/
	* gcc.dg/vect/vect-sdiv-pow2-1.c (main): Add an asm to the
	set-up loop.

diff --git a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
index be70bc6c47e..484efb1e8c8 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-sdiv-pow2-1.c
@@ -62,7 +62,10 @@ main (void)
     {
       int p = power2 (fns[i].po2);
       for (int j = 0; j < N; j++)
-        a[j] = ((p << 4) * j) / (N - 1) - (p << 5);
+	{
+	  a[j] = ((p << 4) * j) / (N - 1) - (p << 5);
+	  asm volatile ("" ::: "memory");
+	}
 
       fns[i].div (b, a, N);
       fns[i].mod (c, a, N);
-- 
2.17.1


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

end of thread, other threads:[~2020-11-18 18:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 11:23 [PATCH 1/5] testsuite: Fix vect/vect-sdiv-pow2-1.c Richard Sandiford
2020-11-17 12:57 ` Richard Biener
2020-11-17 13:02   ` Richard Sandiford
2020-11-18  7:57     ` Richard Biener
2020-11-18 18:44       ` 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).