]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add regtest for amd64 implementation of maskmovq and maskmovdq.
authorJulian Seward <jseward@acm.org>
Sat, 1 Sep 2007 18:58:54 +0000 (18:58 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 1 Sep 2007 18:58:54 +0000 (18:58 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6794

none/tests/amd64/Makefile.am
none/tests/amd64/bug137714-amd64.c [new file with mode: 0644]
none/tests/amd64/bug137714-amd64.stderr.exp [new file with mode: 0644]
none/tests/amd64/bug137714-amd64.stdout.exp [new file with mode: 0644]
none/tests/amd64/bug137714-amd64.vgtest [new file with mode: 0644]

index 0491e9ff5df6d147d2869df6c480be227aabc793..f5a29f3db13ca25af1d7d66fd55ba071d8c465d6 100644 (file)
@@ -15,6 +15,8 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        bug127521-64.vgtest bug127521-64.stdout.exp bug127521-64.stderr.exp \
        bug132813-amd64.vgtest bug132813-amd64.stdout.exp \
        bug132813-amd64.stderr.exp \
+       bug137714-amd64.vgtest bug137714-amd64.stdout.exp \
+       bug137714-amd64.stderr.exp \
        bug132918.vgtest bug132918.stderr.exp bug132918.stdout.exp \
        clc.vgtest clc.stdout.exp clc.stderr.exp \
        faultstatus.disabled faultstatus.stderr.exp \
@@ -36,7 +38,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
 
 
 check_PROGRAMS = \
-       bug127521-64 bug132813-amd64 bug132918 \
+       bug127521-64 bug132813-amd64 bug137714-amd64 bug132918 \
        clc \
        faultstatus fcmovnu fxtract $(INSN_TESTS) looper jrcxz \
        rcl-amd64 smc1 shrld \
diff --git a/none/tests/amd64/bug137714-amd64.c b/none/tests/amd64/bug137714-amd64.c
new file mode 100644 (file)
index 0000000..efa91b5
--- /dev/null
@@ -0,0 +1,110 @@
+
+#include <stdio.h>
+#include <malloc.h>
+#include <assert.h>
+
+typedef  unsigned char  UChar;
+typedef  unsigned int   UInt;
+
+static UInt randomUInt ( void )
+{
+   static UInt n = 0;
+   /* From "Numerical Recipes in C" 2nd Edition */
+   n = 1664525UL * n + 1013904223UL;
+   return n >> 17;
+}
+
+void maskmovq_mmx ( UChar* regL, UChar* regR )
+{
+   int i;
+   UChar* dst = malloc(8);
+   assert(dst);
+   for (i = 0; i < 8; i++)
+      dst[i] = 17 * (i+1);
+   __asm__ __volatile__(
+      "emms\n\t"
+      "movq (%0), %%mm1\n\t"
+      "movq (%1), %%mm2\n\t"
+      "movq %2, %%rdi\n\t"
+      "maskmovq %%mm1,%%mm2"
+      : /*out*/ 
+      : /*in*/ "r"(regL), "r"(regR), "r"(&dst[0])
+      : /*trash*/ "rdi", "memory", "cc"
+   );
+   for (i = 0; i < 8; i++)
+      printf("%02x", dst[i]);
+   free(dst);
+}
+
+void maskmovdqu_sse ( UChar* regL, UChar* regR )
+{
+   int i;
+   UChar* dst = malloc(16);
+   assert(dst);
+   for (i = 0; i < 16; i++)
+      dst[i] = i;
+   __asm__ __volatile__(
+      "movups (%0), %%xmm1\n\t"
+      "movups (%1), %%xmm12\n\t"
+      "movq %2, %%rdi\n\t"
+      "maskmovdqu %%xmm12,%%xmm1\n\t"
+      "sfence"
+      : /*out*/ 
+      : /*in*/ "r"(regL), "r"(regR), "r"(dst)
+      : /*trash*/ "rdi", "memory", "cc"
+   );
+   for (i = 0; i < 16; i++)
+      printf("%02x", dst[i]);
+   free(dst);
+}
+
+int main ( int argc, char** argv )
+{
+   int i, j;
+
+   /* mmx test */
+   {
+      UChar* regL = malloc(8);
+      UChar* regR = malloc(8);
+      assert(regL);
+      assert(regR);
+      for (i = 0; i < 10; i++) {
+         for (j = 0; j < 8; j++) {
+            regL[j] = (UChar)randomUInt();
+            printf("%02x", regL[j]);
+         }
+         printf(" ");
+         for (j = 0; j < 8; j++) {
+            regR[j] = (UChar)randomUInt();
+            printf("%02x", regR[j]);
+         }
+         printf(" ");
+         maskmovq_mmx( regR, regL );
+         printf("\n");
+      }
+   }
+
+   /* sse test */
+   {
+      UChar* regL = malloc(16);
+      UChar* regR = malloc(16);
+      assert(regL);
+      assert(regR);
+      for (i = 0; i < 10; i++) {
+         for (j = 0; j < 16; j++) {
+            regL[j] = (UChar)randomUInt();
+            printf("%02x", regL[j]);
+         }
+         printf(" ");
+         for (j = 0; j < 16; j++) {
+            regR[j] = (UChar)randomUInt();
+            printf("%02x", regR[j]);
+         }
+         printf(" ");
+         maskmovdqu_sse( regR, regL );
+         printf("\n");
+      }
+   }
+
+   return 0;
+}
diff --git a/none/tests/amd64/bug137714-amd64.stderr.exp b/none/tests/amd64/bug137714-amd64.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/amd64/bug137714-amd64.stdout.exp b/none/tests/amd64/bug137714-amd64.stdout.exp
new file mode 100644 (file)
index 0000000..d93cace
--- /dev/null
@@ -0,0 +1,20 @@
+37a8e67c2997ffec fe78fb68914bdde3 3722e6442966ffec
+96e427842e563da3 96f9e55dff19ead5 96e427442e663da3
+773ce009050f014e d4ed3569860c2f4a 773c334405667788
+a945b466477ff7b0 97b91f34d1b2e952 a9453344477ff788
+1e366994ad06eb2b e163f80ba73973a1 1e226944ad66772b
+e5e4e32e0ea1cbc2 d19434d8f1704b89 e5e4332e0e6677c2
+2fc8266f63f0a218 a9906724b7c60dfd 2fc8334463f07718
+4df75731c5319d6f c93f471b234a758f 4d2233445566776f
+af27bbf06c4208a9 b127a8877ca85f72 af22bbf055427788
+e5b0b5c4b1a25149 026e7dd32b31c977 112233c455665188
+a187cb690d7004717ddbdd08b9d3cf13 b244a13a1769cce401d5fbd2ce1bad57 b244a1030405060708d5fb0bce1bad0f
+0a1cfc3088ed770590622b7c323ac0f5 b8e7bfe739f9f1d64928e2eecefc8440 0001bf0339f9060749090a0b0c0d8440
+ed1af098222d47f96e6eb6b5abd1972c facdb31f5dc7a4b05f1b59faf0c7b349 fa01b31f040506b0080959faf0c7b30f
+4fb54cf520a557e09db4a189e78cb6cb 7d2a2036c545ca09c76183caf9709d84 002a023604450609c76183caf9709d84
+3421b49cc4c88b4f9ee812caac6083e7 4431ab81b7ea467304b08333abeca606 0001ab81b7ea460704b00a33ab0da606
+9f91cbdf540ac8d9f8be2b4ebd416193 5418f8527527fc839aba7e07cc2e32e2 5418f8520405fc839aba0a0bcc0d0ee2
+943b371413e0f0142cea11e8de22b5e5 b011abff4572d1cd0e35981c1e2aa62d b00102030472d10708350a1c1e0da62d
+18529a8e44bdea91c120e76dd3f7e2ef 5d5267db693fa7e4e4d3f44567d565fb 000167db043fa7e4e409f40b67d565fb
+2f0999a12d1697e73814d3af60b54cc5 5e0dd23a2701645d9f49b7566923d35f 0001d23a0405645d0809b7560c230e5f
+dc95d7a1105edda81879f784494f577c b8778e70c22ceccbc34b0623ea06556e b8778e700405eccb080906230c0d0e0f
diff --git a/none/tests/amd64/bug137714-amd64.vgtest b/none/tests/amd64/bug137714-amd64.vgtest
new file mode 100644 (file)
index 0000000..0253184
--- /dev/null
@@ -0,0 +1,2 @@
+prog: bug137714-amd64
+vgopts: -q