From: Julian Seward Date: Tue, 6 Feb 2018 14:19:24 +0000 (+0100) Subject: amd64: implement PCMPxSTRx case 0x41. This is generated by recent MSVCs. n-i-bz. X-Git-Tag: VALGRIND_3_14_0~162 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e8c986b203aa99254342c182fd4cf6f1d8190f0;p=thirdparty%2Fvalgrind.git amd64: implement PCMPxSTRx case 0x41. This is generated by recent MSVCs. n-i-bz. --- diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c index 9073e1d36e..d00f45331c 100644 --- a/VEX/priv/guest_amd64_toIR.c +++ b/VEX/priv/guest_amd64_toIR.c @@ -18811,7 +18811,7 @@ static Long dis_PCMPxSTRx ( const VexAbiInfo* vbi, Prefix pfx, case 0x13: case 0x19: case 0x1B: case 0x39: case 0x3B: - case 0x45: + case 0x41: case 0x45: case 0x4B: break; default: diff --git a/VEX/priv/guest_generic_x87.c b/VEX/priv/guest_generic_x87.c index d1979efcc9..28c58b9ba6 100644 --- a/VEX/priv/guest_generic_x87.c +++ b/VEX/priv/guest_generic_x87.c @@ -1052,10 +1052,14 @@ Bool compute_PCMPxSTRx_wide ( /*OUT*/V128* resV, even if they would probably work. Life is too short to have unvalidated cases in the code base. */ switch (imm8) { - case 0x01: case 0x03: case 0x09: case 0x0B: case 0x0D: - case 0x13: case 0x19: case 0x1B: - case 0x39: case 0x3B: - case 0x45: case 0x4B: + // 1,9 3,B 5,D 7,F + case 0x01: case 0x03: + case 0x09: case 0x0B: case 0x0D: + case 0x13: + case 0x19: case 0x1B: + case 0x39: case 0x3B: + case 0x41: case 0x45: + case 0x4B: break; default: return False; diff --git a/none/tests/amd64/pcmpstr64w.c b/none/tests/amd64/pcmpstr64w.c index 6a1adad8cd..f58781388a 100644 --- a/none/tests/amd64/pcmpstr64w.c +++ b/none/tests/amd64/pcmpstr64w.c @@ -208,10 +208,14 @@ Bool pcmpXstrX_WRK_wide ( /*OUT*/V128* resV, even if they would probably work. Life is too short to have unvalidated cases in the code base. */ switch (imm8) { - case 0x01: case 0x03: case 0x09: case 0x0B: case 0x0D: - case 0x13: case 0x19: case 0x1B: - case 0x39: case 0x3B: - case 0x45: case 0x4B: + // 1,9 3,B 5,D 7,F + case 0x01: case 0x03: + case 0x09: case 0x0B: case 0x0D: + case 0x13: + case 0x19: case 0x1B: + case 0x39: case 0x3B: + case 0x41: case 0x45: + case 0x4B: break; default: return False; @@ -1346,6 +1350,85 @@ void istri_19 ( void ) +////////////////////////////////////////////////////////// +// // +// ISTRI_41 // +// // +////////////////////////////////////////////////////////// + +UInt h_pcmpistri_41 ( V128* argL, V128* argR ) +{ + V128 block[2]; + memcpy(&block[0], argL, sizeof(V128)); + memcpy(&block[1], argR, sizeof(V128)); + ULong res, flags; + __asm__ __volatile__( + "subq $1024, %%rsp" "\n\t" + "movdqu 0(%2), %%xmm2" "\n\t" + "movdqu 16(%2), %%xmm11" "\n\t" + "pcmpistri $0x41, %%xmm2, %%xmm11" "\n\t" + "pushfq" "\n\t" + "popq %%rdx" "\n\t" + "movq %%rcx, %0" "\n\t" + "movq %%rdx, %1" "\n\t" + "addq $1024, %%rsp" "\n\t" + : /*out*/ "=r"(res), "=r"(flags) : "r"/*in*/(&block[0]) + : "rcx","rdx","xmm0","xmm2","xmm11","cc","memory" + ); + return ((flags & 0x8D5) << 16) | (res & 0xFFFF); +} + +UInt s_pcmpistri_41 ( V128* argLU, V128* argRU ) +{ + V128 resV; + UInt resOSZACP, resECX; + Bool ok + = pcmpXstrX_WRK_wide( &resV, &resOSZACP, argLU, argRU, + zmask_from_V128(argLU), + zmask_from_V128(argRU), + 0x41, False/*!isSTRM*/ + ); + assert(ok); + resECX = resV.uInt[0]; + return (resOSZACP << 16) | resECX; +} + +void istri_41 ( void ) +{ + char* wot = "41"; + UInt(*h)(V128*,V128*) = h_pcmpistri_41; + UInt(*s)(V128*,V128*) = s_pcmpistri_41; + + try_istri(wot,h,s, "aaaabbbbccccdddd", "000000000000bbcc"); + try_istri(wot,h,s, "aaaabbbbccccdddd", "000000000000ccbb"); + try_istri(wot,h,s, "baaabbbbccccdddd", "000000000000ccbb"); + try_istri(wot,h,s, "baaabbbbccccdddc", "000000000000ccbb"); + + try_istri(wot,h,s, "bbbbbbbbbbbbbbbb", "000000000000ccbb"); + try_istri(wot,h,s, "bbbbbbbb00bbbbbb", "000000000000ccbb"); + try_istri(wot,h,s, "bbbbbbbbbbbb00bb", "000000000000ccbb"); + try_istri(wot,h,s, "bbbbbbbbbbbbbb00", "000000000000ccbb"); + try_istri(wot,h,s, "0000000000000000", "000000000000ccbb"); + + try_istri(wot,h,s, "0000000000000000", "0000000000000000"); + + try_istri(wot,h,s, "bbbbbbbbbbbbbbbb", "000000000000ccbb"); + try_istri(wot,h,s, "bbbbbbbbbbbbbbbb", "00000000000000bb"); + try_istri(wot,h,s, "bb44bb44bb44bb44", "000000006622ccbb"); + + try_istri(wot,h,s, "bb44bb44bb44bb44", "000000000022ccbb"); + try_istri(wot,h,s, "bb44bb44bb44bb44", "000000000000ccbb"); + try_istri(wot,h,s, "bb44bb44bb44bb44", "00000000000000bb"); + + try_istri(wot,h,s, "0011223344556677", "0000997755442211"); + try_istri(wot,h,s, "1122334455667711", "0000997755442211"); + + try_istri(wot,h,s, "0011223344556677", "0000aa8866553322"); + try_istri(wot,h,s, "1122334455667711", "0000aa8866553322"); +} + + + ////////////////////////////////////////////////////////// // // // main // @@ -1365,5 +1448,6 @@ int main ( void ) istri_01(); istri_39(); istri_19(); + istri_41(); return 0; } diff --git a/none/tests/amd64/pcmpstr64w.stdout.exp b/none/tests/amd64/pcmpstr64w.stdout.exp index c18184c442..c1b27bd289 100644 --- a/none/tests/amd64/pcmpstr64w.stdout.exp +++ b/none/tests/amd64/pcmpstr64w.stdout.exp @@ -288,3 +288,23 @@ istri 19 8000000000000000 aaaaaaaa00aaaaaa -> 08c10000 08c10000 istri 19 0000000000000001 aaaaaaaa00aaaaaa -> 08c10000 08c10000 istri 19 0000000000000000 aaaaaaaaaaaaaaaa -> 08410000 08410000 istri 19 aaaaaaaaaaaaaaaa 0000000000000000 -> 08810000 08810000 +istri 41 aaaabbbbccccdddd 000000000000bbcc -> 00810005 00810005 +istri 41 aaaabbbbccccdddd 000000000000ccbb -> 00810005 00810005 +istri 41 baaabbbbccccdddd 000000000000ccbb -> 00810005 00810005 +istri 41 baaabbbbccccdddc 000000000000ccbb -> 00810005 00810005 +istri 41 bbbbbbbbbbbbbbbb 000000000000ccbb -> 08810007 08810007 +istri 41 bbbbbbbb00bbbbbb 000000000000ccbb -> 08c10002 08c10002 +istri 41 bbbbbbbbbbbb00bb 000000000000ccbb -> 08c10000 08c10000 +istri 41 bbbbbbbbbbbbbb00 000000000000ccbb -> 00c00008 00c00008 +istri 41 0000000000000000 000000000000ccbb -> 00c00008 00c00008 +istri 41 0000000000000000 0000000000000000 -> 00c00008 00c00008 +istri 41 bbbbbbbbbbbbbbbb 000000000000ccbb -> 08810007 08810007 +istri 41 bbbbbbbbbbbbbbbb 00000000000000bb -> 08810007 08810007 +istri 41 bb44bb44bb44bb44 000000006622ccbb -> 00810007 00810007 +istri 41 bb44bb44bb44bb44 000000000022ccbb -> 00810007 00810007 +istri 41 bb44bb44bb44bb44 000000000000ccbb -> 00810007 00810007 +istri 41 bb44bb44bb44bb44 00000000000000bb -> 00810007 00810007 +istri 41 0011223344556677 0000997755442211 -> 08c10006 08c10006 +istri 41 1122334455667711 0000997755442211 -> 08810007 08810007 +istri 41 0011223344556677 0000aa8866553322 -> 00c10005 00c10005 +istri 41 1122334455667711 0000aa8866553322 -> 00810006 00810006