From d09681ca709b4d0a14909b09e930d517dbad7c35 Mon Sep 17 00:00:00 2001 From: Josef Weidendorfer Date: Wed, 25 Jul 2012 09:49:26 +0000 Subject: [PATCH] Additions to PCMPxSTRx tests to check fix for bug 303963. Some tests used movdqa triggering a seg fault. Use movdqu instead. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12780 --- none/tests/amd64/pcmpstr64.c | 15 ++++++++++----- none/tests/amd64/pcmpstr64w.c | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/none/tests/amd64/pcmpstr64.c b/none/tests/amd64/pcmpstr64.c index 7d508f90f4..b3a07b515d 100644 --- a/none/tests/amd64/pcmpstr64.c +++ b/none/tests/amd64/pcmpstr64.c @@ -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"); } diff --git a/none/tests/amd64/pcmpstr64w.c b/none/tests/amd64/pcmpstr64w.c index 7f408fc062..7c08b2565e 100644 --- a/none/tests/amd64/pcmpstr64w.c +++ b/none/tests/amd64/pcmpstr64w.c @@ -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"); } -- 2.47.2