Additions to PCMPxSTRx tests to check fix for bug 303963.
authorweidendo <weidendo@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Wed, 25 Jul 2012 09:49:26 +0000 (09:49 +0000)
committerweidendo <weidendo@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Wed, 25 Jul 2012 09:49:26 +0000 (09:49 +0000)
Some tests used movdqa triggering a seg fault. Use movdqu instead.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12780 a5019735-40e9-0310-863c-91ae7b9d1cf9

none/tests/amd64/pcmpstr64.c
none/tests/amd64/pcmpstr64w.c

index 7d508f90f4da99317300f62c8c012cfc6388833f..b3a07b515df00d77fa84edb6a6dc3af668325755 100644 (file)
@@ -305,9 +305,6 @@ Bool pcmpXstrX_WRK ( /*OUT*/V128* resV,
       UInt   validL  = ~(zmaskL | -zmaskL);  // not(left(zmaskL))
       UInt   validR  = ~(zmaskR | -zmaskR);  // not(left(zmaskR))
       for (hi = 0; hi < 16; hi++) {
-         if ((validL & (1 << hi)) == 0)
-            // run off the end of the haystack
-            break;
          UInt m = 1;
          for (ni = 0; ni < 16; ni++) {
             if ((validR & (1 << ni)) == 0) break;
@@ -316,6 +313,9 @@ Bool pcmpXstrX_WRK ( /*OUT*/V128* resV,
             if (argL[i] != argR[ni]) { m = 0; break; }
          }
          boolRes |= (m << hi);
+         if ((validL & (1 << hi)) == 0)
+            // run off the end of the haystack
+            break;
       }
 
       // boolRes is "pre-invalidated"
@@ -573,8 +573,8 @@ UInt h_pcmpistri_0C ( V128* argL, V128* argR )
    memcpy(&block[1], argR, sizeof(V128));
    ULong res = 0, flags = 0;
    __asm__ __volatile__(
-      "movdqa    0(%2),  %%xmm2"            "\n\t"
-      "movdqa    16(%2), %%xmm11"           "\n\t"
+      "movdqu    0(%2),  %%xmm2"            "\n\t"
+      "movdqu    16(%2), %%xmm11"           "\n\t"
       "pcmpistri $0x0C,  %%xmm2, %%xmm11"   "\n\t"
       //"pcmpistrm $0x0C,  %%xmm2, %%xmm11"   "\n\t"
       //"movd %%xmm0, %%ecx" "\n\t"
@@ -639,6 +639,11 @@ void istri_0C ( void )
    try_istri(wot,h,s, "1111111111111234", "1111111111111234"); 
    try_istri(wot,h,s, "a111111111111111", "000000000000000a"); 
    try_istri(wot,h,s, "b111111111111111", "000000000000000a"); 
+
+   try_istri(wot,h,s, "b111111111111111", "0000000000000000");
+   try_istri(wot,h,s, "0000000000000000", "0000000000000000");
+   try_istri(wot,h,s, "123456789abcdef1", "0000000000000000");
+   try_istri(wot,h,s, "0000000000000000", "123456789abcdef1");
 }
 
 
index 7f408fc062523f532e49babc36aa2d66fdcb9d1e..7c08b2565e862e76388cd9a24df92fcca1a8be6c 100644 (file)
@@ -308,9 +308,6 @@ Bool pcmpXstrX_WRK_wide ( /*OUT*/V128* resV,
       UInt   validL  = ~(zmaskL | -zmaskL);  // not(left(zmaskL))
       UInt   validR  = ~(zmaskR | -zmaskR);  // not(left(zmaskR))
       for (hi = 0; hi < 8; hi++) {
-         if ((validL & (1 << hi)) == 0)
-            // run off the end of the haystack
-            break;
          UInt m = 1;
          for (ni = 0; ni < 8; ni++) {
             if ((validR & (1 << ni)) == 0) break;
@@ -319,6 +316,9 @@ Bool pcmpXstrX_WRK_wide ( /*OUT*/V128* resV,
             if (argL[i] != argR[ni]) { m = 0; break; }
          }
          boolRes |= (m << hi);
+         if ((validL & (1 << hi)) == 0)
+            // run off the end of the haystack
+            break;
       }
 
       // boolRes is "pre-invalidated"
@@ -574,8 +574,8 @@ UInt h_pcmpistri_0D ( V128* argL, V128* argR )
    memcpy(&block[1], argR, sizeof(V128));
    ULong res = 0, flags = 0;
    __asm__ __volatile__(
-      "movdqa    0(%2),  %%xmm2"            "\n\t"
-      "movdqa    16(%2), %%xmm11"           "\n\t"
+      "movdqu    0(%2),  %%xmm2"            "\n\t"
+      "movdqu    16(%2), %%xmm11"           "\n\t"
       "pcmpistri $0x0D,  %%xmm2, %%xmm11"   "\n\t"
       //"pcmpistrm $0x0D,  %%xmm2, %%xmm11"   "\n\t"
       //"movd %%xmm0, %%ecx" "\n\t"
@@ -638,6 +638,11 @@ void istri_0D ( void )
    try_istri(wot,h,s, "1111111111111234", "1111111111111234");
    try_istri(wot,h,s, "0a11111111111111", "000000000000000a");
    try_istri(wot,h,s, "0b11111111111111", "000000000000000a");
+
+   try_istri(wot,h,s, "b111111111111111", "0000000000000000");
+   try_istri(wot,h,s, "0000000000000000", "0000000000000000");
+   try_istri(wot,h,s, "123456789abcdef1", "0000000000000000");
+   try_istri(wot,h,s, "0000000000000000", "123456789abcdef1");
 }