Patchwork [testsuite,i386] Reimplementing array comparison in avx2-vpop-check.h

login
register
mail settings
Submitter Alexander Ivchenko
Date April 11, 2013, 11:58 a.m.
Message ID <CACysShgf2tV1yid9qG1=nfmNGvWhSj7M76Lt7RPaP7yRNpA1yw@mail.gmail.com>
Download mbox | patch
Permalink /patch/235711/
State New
Headers show

Comments

Alexander Ivchenko - April 11, 2013, 11:58 a.m.
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:



is it OK?

thanks,
Alexander
Richard Guenther - April 11, 2013, 12:42 p.m.
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

Patch

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();
     }
 }