public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [testsuite, i386] Reimplementing array comparison in avx2-vpop-check.h
@ 2013-04-11 12:37 Alexander Ivchenko
  2013-04-11 13:10 ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Ivchenko @ 2013-04-11 12:37 UTC (permalink / raw)
  To: GCC Patches, Uros Bizjak

Hi,

Usually <stdlib.h> does not include <string.h> but on bionic it is
historically included. memcmp() reacts on a volatile argument
differently, depending on whether <string.h> is included or not. If it
is included, then the compiler will generate a warning:
warning: passing argument 2 of 'memcmp' discards 'volatile' qualifier
from pointer target type [enabled by default]

In avx2-vpop-check.h we compare two arrays using memcmp(), and since
one of them is declared as volatile we have test-fails because of that
warning. The following patch reimplements the comparison using just
for-loop:

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 943be90..9b08eb0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2013-04-11  Grigoriy Kraynov  <grigoriy.kraynov@intel.com>
+
+       * gcc.target/i386/avx2-vpop-check.h: memcmp() replaced by for loop.
+
 2013-04-11  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/54216
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
index 143b54da..921ed0b 100644
--- a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
@@ -47,7 +47,8 @@ avx2_test (void)
       gen_pop ();
       check_pop ();

-      if (memcmp (c, c_ref, SIZE * sizeof (TYPE)))
-       abort();
+      for (i = 0; i < SIZE; ++i)
+        if (c[i] != c_ref[i])
+          abort();
     }
 }


is it OK?

thanks,
Alexander

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

* Re: [testsuite, i386] Reimplementing array comparison in avx2-vpop-check.h
  2013-04-11 12:37 [testsuite, i386] Reimplementing array comparison in avx2-vpop-check.h Alexander Ivchenko
@ 2013-04-11 13:10 ` Richard Biener
  2013-04-18 13:48   ` Alexander Ivchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2013-04-11 13:10 UTC (permalink / raw)
  To: Alexander Ivchenko; +Cc: GCC Patches, Uros Bizjak

On Thu, Apr 11, 2013 at 1:58 PM, Alexander Ivchenko <aivchenk@gmail.com> wrote:
> Hi,
>
> Usually <stdlib.h> does not include <string.h> but on bionic it is
> historically included. memcmp() reacts on a volatile argument
> differently, depending on whether <string.h> is included or not. If it
> is included, then the compiler will generate a warning:
> warning: passing argument 2 of 'memcmp' discards 'volatile' qualifier
> from pointer target type [enabled by default]
>
> In avx2-vpop-check.h we compare two arrays using memcmp(), and since
> one of them is declared as volatile we have test-fails because of that
> warning. The following patch reimplements the comparison using just
> for-loop:
>
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index 943be90..9b08eb0 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,7 @@
> +2013-04-11  Grigoriy Kraynov  <grigoriy.kraynov@intel.com>
> +
> +       * gcc.target/i386/avx2-vpop-check.h: memcmp() replaced by for loop.
> +
>  2013-04-11  Paolo Carlini  <paolo.carlini@oracle.com>
>
>         PR c++/54216
> diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
> b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
> index 143b54da..921ed0b 100644
> --- a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
> +++ b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
> @@ -47,7 +47,8 @@ avx2_test (void)
>        gen_pop ();
>        check_pop ();
>
> -      if (memcmp (c, c_ref, SIZE * sizeof (TYPE)))
> -       abort();
> +      for (i = 0; i < SIZE; ++i)
> +        if (c[i] != c_ref[i])
> +          abort();
>      }
>  }
>
>
> is it OK?

Just cast away the volatileness?  memcmp (c, (void *)c_ref, ...)?

Richard.

> thanks,
> Alexander

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

* Re: [testsuite, i386] Reimplementing array comparison in avx2-vpop-check.h
  2013-04-11 13:10 ` Richard Biener
@ 2013-04-18 13:48   ` Alexander Ivchenko
  2013-04-18 13:49     ` Uros Bizjak
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Ivchenko @ 2013-04-18 13:48 UTC (permalink / raw)
  To: Richard Biener, GCC Patches, Uros Bizjak

Yep, that also works.

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 64ffe8f..7efc3f1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-18  Grigoriy Kraynov  <grigoriy.kraynov@intel.com>
+
+       * gcc.target/i386/avx2-vpop-check.h: volatility is casted away in
+       memcmp().
+
 2013-04-18  Jakub Jelinek  <jakub@redhat.com>

        PR tree-optimization/56984
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
index 143b54da..02c879e 100644
--- a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
@@ -47,7 +47,7 @@ avx2_test (void)
       gen_pop ();
       check_pop ();

-      if (memcmp (c, c_ref, SIZE * sizeof (TYPE)))
+      if (memcmp (c, (void *) c_ref, SIZE * sizeof (TYPE)))
        abort();
     }
 }


The fix is pretty obvious, but still.. is it OK for trunk?

thanks,
Alexander


2013/4/11 Richard Biener <richard.guenther@gmail.com>:
> On Thu, Apr 11, 2013 at 1:58 PM, Alexander Ivchenko <aivchenk@gmail.com> wrote:
>> Hi,
>>
>> Usually <stdlib.h> does not include <string.h> but on bionic it is
>> historically included. memcmp() reacts on a volatile argument
>> differently, depending on whether <string.h> is included or not. If it
>> is included, then the compiler will generate a warning:
>> warning: passing argument 2 of 'memcmp' discards 'volatile' qualifier
>> from pointer target type [enabled by default]
>>
>> In avx2-vpop-check.h we compare two arrays using memcmp(), and since
>> one of them is declared as volatile we have test-fails because of that
>> warning. The following patch reimplements the comparison using just
>> for-loop:
>>
>> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
>> index 943be90..9b08eb0 100644
>> --- a/gcc/testsuite/ChangeLog
>> +++ b/gcc/testsuite/ChangeLog
>> @@ -1,3 +1,7 @@
>> +2013-04-11  Grigoriy Kraynov  <grigoriy.kraynov@intel.com>
>> +
>> +       * gcc.target/i386/avx2-vpop-check.h: memcmp() replaced by for loop.
>> +
>>  2013-04-11  Paolo Carlini  <paolo.carlini@oracle.com>
>>
>>         PR c++/54216
>> diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
>> b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
>> index 143b54da..921ed0b 100644
>> --- a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
>> +++ b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
>> @@ -47,7 +47,8 @@ avx2_test (void)
>>        gen_pop ();
>>        check_pop ();
>>
>> -      if (memcmp (c, c_ref, SIZE * sizeof (TYPE)))
>> -       abort();
>> +      for (i = 0; i < SIZE; ++i)
>> +        if (c[i] != c_ref[i])
>> +          abort();
>>      }
>>  }
>>
>>
>> is it OK?
>
> Just cast away the volatileness?  memcmp (c, (void *)c_ref, ...)?
>
> Richard.
>
>> thanks,
>> Alexander

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

* Re: [testsuite, i386] Reimplementing array comparison in avx2-vpop-check.h
  2013-04-18 13:48   ` Alexander Ivchenko
@ 2013-04-18 13:49     ` Uros Bizjak
  2013-04-18 18:25       ` Kirill Yukhin
  0 siblings, 1 reply; 5+ messages in thread
From: Uros Bizjak @ 2013-04-18 13:49 UTC (permalink / raw)
  To: Alexander Ivchenko; +Cc: Richard Biener, GCC Patches

On Thu, Apr 18, 2013 at 12:10 PM, Alexander Ivchenko <aivchenk@gmail.com> wrote:
> Yep, that also works.
>
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index 64ffe8f..7efc3f1 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2013-04-18  Grigoriy Kraynov  <grigoriy.kraynov@intel.com>
> +
> +       * gcc.target/i386/avx2-vpop-check.h: volatility is casted away in
> +       memcmp().
> +
>  2013-04-18  Jakub Jelinek  <jakub@redhat.com>
>
>         PR tree-optimization/56984
> diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
> b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
> index 143b54da..02c879e 100644
> --- a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
> +++ b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h
> @@ -47,7 +47,7 @@ avx2_test (void)
>        gen_pop ();
>        check_pop ();
>
> -      if (memcmp (c, c_ref, SIZE * sizeof (TYPE)))
> +      if (memcmp (c, (void *) c_ref, SIZE * sizeof (TYPE)))
>         abort();
>      }
>  }
>
>
> The fix is pretty obvious, but still.. is it OK for trunk?

Please add a short comment on the purpose of the cast.

OK with that change.

Thanks,
Uros.

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

* Re: [testsuite, i386] Reimplementing array comparison in avx2-vpop-check.h
  2013-04-18 13:49     ` Uros Bizjak
@ 2013-04-18 18:25       ` Kirill Yukhin
  0 siblings, 0 replies; 5+ messages in thread
From: Kirill Yukhin @ 2013-04-18 18:25 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: Alexander Ivchenko, Richard Biener, GCC Patches

> OK with that change.
Hi,
Checked into trunk: http://gcc.gnu.org/ml/gcc-cvs/2013-04/msg00763.html

Thanks, K

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

end of thread, other threads:[~2013-04-18 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11 12:37 [testsuite, i386] Reimplementing array comparison in avx2-vpop-check.h Alexander Ivchenko
2013-04-11 13:10 ` Richard Biener
2013-04-18 13:48   ` Alexander Ivchenko
2013-04-18 13:49     ` Uros Bizjak
2013-04-18 18:25       ` Kirill Yukhin

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