public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Repost: [PATCH] Fix vec-splati-runnable.c test.
@ 2021-07-07 20:00 Michael Meissner
  2021-07-12 15:49 ` Bill Schmidt
  2021-07-12 20:04 ` David Edelsohn
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Meissner @ 2021-07-07 20:00 UTC (permalink / raw)
  To: gcc-patches, Michael Meissner, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner, Will Schmidt

[PATCH] Fix vec-splati-runnable.c test.

I noticed that the vec-splati-runnable.c did not have an abort after one
of the tests.  If the test was run with optimization, the optimizer could
delete some of the tests and throw off the count.  However, due to the
fact that the value being loaded in that test is undefined, I did not
check what value was loaded, but I just stored it into a volatile global
variable.

2021-07-07  Michael Meissner  <meissner@linux.ibm.com>

gcc/testsuite/
	* gcc.target/powerpc/vec-splati-runnable.c: Run test with -O2
	optimization.  Do not check what XXSPLTIDP generates if the value
	is undefined.
---
 .../gcc.target/powerpc/vec-splati-runnable.c  | 29 ++++++-------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c b/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
index e84ce77a21d..a135279b1d7 100644
--- a/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
+++ b/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
@@ -1,7 +1,7 @@
 /* { dg-do run { target { power10_hw } } } */
 /* { dg-do link { target { ! power10_hw } } } */
 /* { dg-require-effective-target power10_ok } */
-/* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */
+/* { dg-options "-mdejagnu-cpu=power10 -save-temps -O2" } */
 #include <altivec.h>
 
 #define DEBUG 0
@@ -12,6 +12,8 @@
 
 extern void abort (void);
 
+volatile vector double vresult_d_undefined;
+
 int
 main (int argc, char *argv [])
 {
@@ -85,25 +87,12 @@ main (int argc, char *argv [])
 #endif
   }
 
-  /* This test will generate a "note" to the user that the argument
-     is subnormal.  It is not an error, but results are not defined.  */
-  vresult_d = (vector double) { 2.0, 3.0 };
-  expected_vresult_d = (vector double) { 6.6E-42f, 6.6E-42f };
-
-  vresult_d = vec_splatid (6.6E-42f);
-
-  /* Although the instruction says the results are not defined, it does seem
-     to work, at least on Mambo.  But no guarentees!  */
-  if (!vec_all_eq (vresult_d,  expected_vresult_d)) {
-#if DEBUG
-    printf("ERROR, vec_splati (6.6E-42f)\n");
-    for(i = 0; i < 2; i++)
-      printf(" vresult_d[%i] = %e, expected_vresult_d[%i] = %e\n",
-	     i, vresult_d[i], i, expected_vresult_d[i]);
-#else
-    ;
-#endif
-  }
+  /* This test will generate a "note" to the user that the argument is
+     subnormal.  It is not an error, but results are not defined.  Because this
+     is undefined, we cannot check that any value is correct.  Just store it in
+     a volatile variable so the XXSPLTIDP instruction gets generated and the
+     warning message printed. */
+  vresult_d_undefined = vec_splatid (6.6E-42f);
 
   /* Vector splat immediate */
   vsrc_a_int = (vector int) { 2, 3, 4, 5 };
-- 
2.31.1


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

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

* Re: Repost: [PATCH] Fix vec-splati-runnable.c test.
  2021-07-07 20:00 Repost: [PATCH] Fix vec-splati-runnable.c test Michael Meissner
@ 2021-07-12 15:49 ` Bill Schmidt
  2021-07-12 17:11   ` Michael Meissner
  2021-07-12 20:04 ` David Edelsohn
  1 sibling, 1 reply; 5+ messages in thread
From: Bill Schmidt @ 2021-07-12 15:49 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Peter Bergner, Will Schmidt

Hi Mike,

On 7/7/21 3:00 PM, Michael Meissner wrote:
> [PATCH] Fix vec-splati-runnable.c test.
>
> I noticed that the vec-splati-runnable.c did not have an abort after one
> of the tests.  If the test was run with optimization, the optimizer could
> delete some of the tests and throw off the count.  However, due to the
> fact that the value being loaded in that test is undefined, I did not
> check what value was loaded, but I just stored it into a volatile global
> variable.
>
> 2021-07-07  Michael Meissner  <meissner@linux.ibm.com>
>
> gcc/testsuite/
> 	* gcc.target/powerpc/vec-splati-runnable.c: Run test with -O2
> 	optimization.  Do not check what XXSPLTIDP generates if the value
> 	is undefined.
> ---
>   .../gcc.target/powerpc/vec-splati-runnable.c  | 29 ++++++-------------
>   1 file changed, 9 insertions(+), 20 deletions(-)
>
> diff --git a/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c b/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
> index e84ce77a21d..a135279b1d7 100644
> --- a/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
> +++ b/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
> @@ -1,7 +1,7 @@
>   /* { dg-do run { target { power10_hw } } } */
>   /* { dg-do link { target { ! power10_hw } } } */
>   /* { dg-require-effective-target power10_ok } */
> -/* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */
> +/* { dg-options "-mdejagnu-cpu=power10 -save-temps -O2" } */

Why did you restrict optimization here?  The tests should be run at 
various opt levels if you don't specify this, right?

The test changes are otherwise okay, but I'd like to understand this first.

Thanks,
Bill

>   #include <altivec.h>
>   
>   #define DEBUG 0
> @@ -12,6 +12,8 @@
>   
>   extern void abort (void);
>   
> +volatile vector double vresult_d_undefined;
> +
>   int
>   main (int argc, char *argv [])
>   {
> @@ -85,25 +87,12 @@ main (int argc, char *argv [])
>   #endif
>     }
>   
> -  /* This test will generate a "note" to the user that the argument
> -     is subnormal.  It is not an error, but results are not defined.  */
> -  vresult_d = (vector double) { 2.0, 3.0 };
> -  expected_vresult_d = (vector double) { 6.6E-42f, 6.6E-42f };
> -
> -  vresult_d = vec_splatid (6.6E-42f);
> -
> -  /* Although the instruction says the results are not defined, it does seem
> -     to work, at least on Mambo.  But no guarentees!  */
> -  if (!vec_all_eq (vresult_d,  expected_vresult_d)) {
> -#if DEBUG
> -    printf("ERROR, vec_splati (6.6E-42f)\n");
> -    for(i = 0; i < 2; i++)
> -      printf(" vresult_d[%i] = %e, expected_vresult_d[%i] = %e\n",
> -	     i, vresult_d[i], i, expected_vresult_d[i]);
> -#else
> -    ;
> -#endif
> -  }
> +  /* This test will generate a "note" to the user that the argument is
> +     subnormal.  It is not an error, but results are not defined.  Because this
> +     is undefined, we cannot check that any value is correct.  Just store it in
> +     a volatile variable so the XXSPLTIDP instruction gets generated and the
> +     warning message printed. */
> +  vresult_d_undefined = vec_splatid (6.6E-42f);
>   
>     /* Vector splat immediate */
>     vsrc_a_int = (vector int) { 2, 3, 4, 5 };

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

* Re: Repost: [PATCH] Fix vec-splati-runnable.c test.
  2021-07-12 15:49 ` Bill Schmidt
@ 2021-07-12 17:11   ` Michael Meissner
  2021-07-12 17:22     ` Bill Schmidt
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Meissner @ 2021-07-12 17:11 UTC (permalink / raw)
  To: Bill Schmidt
  Cc: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Peter Bergner, Will Schmidt

On Mon, Jul 12, 2021 at 10:49:26AM -0500, Bill Schmidt wrote:
> Hi Mike,
> 
> On 7/7/21 3:00 PM, Michael Meissner wrote:
> >[PATCH] Fix vec-splati-runnable.c test.
> >
> >I noticed that the vec-splati-runnable.c did not have an abort after one
> >of the tests.  If the test was run with optimization, the optimizer could
> >delete some of the tests and throw off the count.  However, due to the
> >fact that the value being loaded in that test is undefined, I did not
> >check what value was loaded, but I just stored it into a volatile global
> >variable.
> >
> >2021-07-07  Michael Meissner  <meissner@linux.ibm.com>
> >
> >gcc/testsuite/
> >	* gcc.target/powerpc/vec-splati-runnable.c: Run test with -O2
> >	optimization.  Do not check what XXSPLTIDP generates if the value
> >	is undefined.
> >---
> >  .../gcc.target/powerpc/vec-splati-runnable.c  | 29 ++++++-------------
> >  1 file changed, 9 insertions(+), 20 deletions(-)
> >
> >diff --git a/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c b/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
> >index e84ce77a21d..a135279b1d7 100644
> >--- a/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
> >+++ b/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
> >@@ -1,7 +1,7 @@
> >  /* { dg-do run { target { power10_hw } } } */
> >  /* { dg-do link { target { ! power10_hw } } } */
> >  /* { dg-require-effective-target power10_ok } */
> >-/* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */
> >+/* { dg-options "-mdejagnu-cpu=power10 -save-temps -O2" } */
> 
> Why did you restrict optimization here?  The tests should be run at
> various opt levels if you don't specify this, right?
> 
> The test changes are otherwise okay, but I'd like to understand this first.

When doing tests with instruction counts, you always want to specify the
optimization level (with -O2 being the standard).  Otherwise, depending on the
other optimizations, the instruction counts might not line up.

In this particular case, because it didn't have an optimization flag, the
original code was compiled with -O0.  If you compile it with -O1, it deletes
the if statement with the empty then statement, and deletes the corresponding
XXSPLTIDP instruction.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

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

* Re: Repost: [PATCH] Fix vec-splati-runnable.c test.
  2021-07-12 17:11   ` Michael Meissner
@ 2021-07-12 17:22     ` Bill Schmidt
  0 siblings, 0 replies; 5+ messages in thread
From: Bill Schmidt @ 2021-07-12 17:22 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Peter Bergner, Will Schmidt

On 7/12/21 12:11 PM, Michael Meissner wrote:
> On Mon, Jul 12, 2021 at 10:49:26AM -0500, Bill Schmidt wrote:
>> Hi Mike,
>>
>> On 7/7/21 3:00 PM, Michael Meissner wrote:
>>> [PATCH] Fix vec-splati-runnable.c test.
>>>
>>> I noticed that the vec-splati-runnable.c did not have an abort after one
>>> of the tests.  If the test was run with optimization, the optimizer could
>>> delete some of the tests and throw off the count.  However, due to the
>>> fact that the value being loaded in that test is undefined, I did not
>>> check what value was loaded, but I just stored it into a volatile global
>>> variable.
>>>
>>> 2021-07-07  Michael Meissner  <meissner@linux.ibm.com>
>>>
>>> gcc/testsuite/
>>> 	* gcc.target/powerpc/vec-splati-runnable.c: Run test with -O2
>>> 	optimization.  Do not check what XXSPLTIDP generates if the value
>>> 	is undefined.
>>> ---
>>>   .../gcc.target/powerpc/vec-splati-runnable.c  | 29 ++++++-------------
>>>   1 file changed, 9 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c b/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
>>> index e84ce77a21d..a135279b1d7 100644
>>> --- a/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
>>> +++ b/gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
>>> @@ -1,7 +1,7 @@
>>>   /* { dg-do run { target { power10_hw } } } */
>>>   /* { dg-do link { target { ! power10_hw } } } */
>>>   /* { dg-require-effective-target power10_ok } */
>>> -/* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */
>>> +/* { dg-options "-mdejagnu-cpu=power10 -save-temps -O2" } */
>> Why did you restrict optimization here?  The tests should be run at
>> various opt levels if you don't specify this, right?
>>
>> The test changes are otherwise okay, but I'd like to understand this first.
> When doing tests with instruction counts, you always want to specify the
> optimization level (with -O2 being the standard).  Otherwise, depending on the
> other optimizations, the instruction counts might not line up.
>
> In this particular case, because it didn't have an optimization flag, the
> original code was compiled with -O0.  If you compile it with -O1, it deletes
> the if statement with the empty then statement, and deletes the corresponding
> XXSPLTIDP instruction.
>
Sorry, yes.  I thought this set of tests was run with all optimization 
flags, but it is not.  Objection withdrawn. :-)

I can't approve, but recommend approval as is.

Thanks,
Bill


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

* Re: Repost: [PATCH] Fix vec-splati-runnable.c test.
  2021-07-07 20:00 Repost: [PATCH] Fix vec-splati-runnable.c test Michael Meissner
  2021-07-12 15:49 ` Bill Schmidt
@ 2021-07-12 20:04 ` David Edelsohn
  1 sibling, 0 replies; 5+ messages in thread
From: David Edelsohn @ 2021-07-12 20:04 UTC (permalink / raw)
  To: Michael Meissner, GCC Patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner, Will Schmidt

On Wed, Jul 7, 2021 at 4:01 PM Michael Meissner <meissner@linux.ibm.com> wrote:
>
> [PATCH] Fix vec-splati-runnable.c test.
>
> I noticed that the vec-splati-runnable.c did not have an abort after one
> of the tests.  If the test was run with optimization, the optimizer could
> delete some of the tests and throw off the count.  However, due to the
> fact that the value being loaded in that test is undefined, I did not
> check what value was loaded, but I just stored it into a volatile global
> variable.
>
> 2021-07-07  Michael Meissner  <meissner@linux.ibm.com>
>
> gcc/testsuite/
>         * gcc.target/powerpc/vec-splati-runnable.c: Run test with -O2
>         optimization.  Do not check what XXSPLTIDP generates if the value
>         is undefined.

Okay.

Thanks, David

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

end of thread, other threads:[~2021-07-12 20:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 20:00 Repost: [PATCH] Fix vec-splati-runnable.c test Michael Meissner
2021-07-12 15:49 ` Bill Schmidt
2021-07-12 17:11   ` Michael Meissner
2021-07-12 17:22     ` Bill Schmidt
2021-07-12 20:04 ` David Edelsohn

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