allow double shufti to share buckets

This commit is contained in:
Alex Coyte
2016-04-04 11:02:59 +10:00
committed by Matthew Barr
parent 6c7ee12bb9
commit c0a5b037a1
3 changed files with 194 additions and 50 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -283,7 +283,9 @@ TEST(DoubleShufti, BuildMask1) {
lits.insert(make_pair('a', 'B'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, &lo2m, &hi2m);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m,
&lo2m, &hi2m);
ASSERT_TRUE(rv);
u8 *lo1 = (u8 *)&lo1m;
u8 *lo2 = (u8 *)&lo2m;
@@ -324,7 +326,9 @@ TEST(DoubleShufti, BuildMask2) {
lits.insert(make_pair('a','z'));
lits.insert(make_pair('B','z'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, &lo2m, &hi2m);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m,
&lo2m, &hi2m);
ASSERT_TRUE(rv);
u8 *lo1 = (u8 *)&lo1m;
u8 *lo2 = (u8 *)&lo2m;
@@ -350,7 +354,9 @@ TEST(DoubleShufti, BuildMask4) {
lits.insert(make_pair('A','z'));
lits.insert(make_pair('b','z'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, &lo2m, &hi2m);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m,
&lo2m, &hi2m);
ASSERT_TRUE(rv);
u8 *lo1 = (u8 *)&lo1m;
u8 *lo2 = (u8 *)&lo2m;
@@ -377,7 +383,9 @@ TEST(DoubleShufti, BuildMask5) {
CharReach bytes;
bytes.set('X');
shuftiBuildDoubleMasks(bytes, lits, &lo1m, &hi1m, &lo2m, &hi2m);
bool rv = shuftiBuildDoubleMasks(bytes, lits, &lo1m, &hi1m,
&lo2m, &hi2m);
ASSERT_TRUE(rv);
u8 *lo1 = (u8 *)&lo1m;
u8 *lo2 = (u8 *)&lo2m;
@@ -395,6 +403,81 @@ TEST(DoubleShufti, BuildMask5) {
lo1['B' % 16] | hi1['B' >> 4] | lo2['X' % 16] | hi2['X' >> 4]);
}
TEST(DoubleShufti, BuildMask6) {
m128 lo1m, hi1m, lo2m, hi2m;
flat_set<pair<u8, u8>> lits;
lits.insert(make_pair('a','z'));
lits.insert(make_pair('B','z'));
lits.insert(make_pair('A','z'));
lits.insert(make_pair('b','z'));
lits.insert(make_pair('a','y'));
lits.insert(make_pair('B','y'));
lits.insert(make_pair('A','y'));
lits.insert(make_pair('b','y'));
lits.insert(make_pair('a','x'));
lits.insert(make_pair('B','x'));
lits.insert(make_pair('A','x'));
lits.insert(make_pair('b','x'));
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m,
&lo2m, &hi2m);
ASSERT_TRUE(rv);
u8 *lo1 = (u8 *)&lo1m;
u8 *lo2 = (u8 *)&lo2m;
u8 *hi1 = (u8 *)&hi1m;
u8 *hi2 = (u8 *)&hi2m;
ASSERT_NE(0xff,
lo1['a' % 16] | hi1['a' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
ASSERT_NE(0xff,
lo1['A' % 16] | hi1['A' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
ASSERT_NE(0xff,
lo1['b' % 16] | hi1['b' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
ASSERT_NE(0xff,
lo1['B' % 16] | hi1['B' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
ASSERT_NE(0xff,
lo1['a' % 16] | hi1['a' >> 4] | lo2['y' % 16] | hi2['y' >> 4]);
ASSERT_NE(0xff,
lo1['A' % 16] | hi1['A' >> 4] | lo2['y' % 16] | hi2['y' >> 4]);
ASSERT_NE(0xff,
lo1['b' % 16] | hi1['b' >> 4] | lo2['y' % 16] | hi2['y' >> 4]);
ASSERT_NE(0xff,
lo1['B' % 16] | hi1['B' >> 4] | lo2['y' % 16] | hi2['y' >> 4]);
ASSERT_NE(0xff,
lo1['a' % 16] | hi1['a' >> 4] | lo2['x' % 16] | hi2['x' >> 4]);
ASSERT_NE(0xff,
lo1['A' % 16] | hi1['A' >> 4] | lo2['x' % 16] | hi2['x' >> 4]);
ASSERT_NE(0xff,
lo1['b' % 16] | hi1['b' >> 4] | lo2['x' % 16] | hi2['x' >> 4]);
ASSERT_NE(0xff,
lo1['B' % 16] | hi1['B' >> 4] | lo2['x' % 16] | hi2['x' >> 4]);
}
TEST(DoubleShufti, BuildMask7) {
m128 lo1m, hi1m, lo2m, hi2m;
flat_set<pair<u8, u8>> lits;
lits.insert(make_pair('a','b'));
lits.insert(make_pair('c','d'));
lits.insert(make_pair('e','f'));
lits.insert(make_pair('g','h'));
lits.insert(make_pair('i','j'));
lits.insert(make_pair('k','l'));
lits.insert(make_pair('m','n'));
lits.insert(make_pair('o','p'));
lits.insert(make_pair('q','r'));
lits.insert(make_pair('s','t'));
lits.insert(make_pair('u','v'));
lits.insert(make_pair('w','x'));
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m,
&lo2m, &hi2m);
ASSERT_FALSE(rv);
}
TEST(DoubleShufti, ExecNoMatch1) {
m128 lo1, hi1, lo2, hi2;
@@ -402,7 +485,9 @@ TEST(DoubleShufti, ExecNoMatch1) {
lits.insert(make_pair('a','b'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1,
&lo2, &hi2);
ASSERT_TRUE(rv);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@@ -421,7 +506,8 @@ TEST(DoubleShufti, ExecNoMatch1b) {
lits.insert(make_pair('b','a'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@@ -441,7 +527,8 @@ TEST(DoubleShufti, ExecNoMatch2) {
lits.insert(make_pair('a','b'));
lits.insert(make_pair('B','b'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@@ -461,7 +548,8 @@ TEST(DoubleShufti, ExecNoMatch2b) {
lits.insert(make_pair('b','a'));
lits.insert(make_pair('b','B'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@@ -480,7 +568,8 @@ TEST(DoubleShufti, ExecNoMatch3) {
lits.insert(make_pair('V','e'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
@@ -499,7 +588,8 @@ TEST(DoubleShufti, ExecNoMatch3b) {
lits.insert(make_pair('e','V'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
@@ -518,7 +608,8 @@ TEST(DoubleShufti, ExecMatch1) {
lits.insert(make_pair('a','b'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbb";
@@ -538,7 +629,8 @@ TEST(DoubleShufti, ExecMatch2) {
lits.insert(make_pair('a','a'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
@@ -559,7 +651,8 @@ TEST(DoubleShufti, ExecMatch3) {
lits.insert(make_pair('B','a'));
lits.insert(make_pair('a','a'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbBaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
@@ -582,8 +675,8 @@ TEST(DoubleShufti, ExecMatch4) {
lits.insert(make_pair('C','a'));
lits.insert(make_pair('c','a'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbAaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
@@ -624,8 +717,8 @@ TEST(DoubleShufti, ExecMatch4b) {
lits.insert(make_pair('a','C'));
lits.insert(make_pair('a','c'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbaAaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
@@ -663,7 +756,8 @@ TEST(DoubleShufti, ExecMatch5) {
lits.insert(make_pair('a','A'));
shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@@ -686,7 +780,8 @@ TEST(DoubleShufti, ExecMatchMixed1) {
// just one one-byte literal
onebyte.set('a');
shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@@ -709,7 +804,8 @@ TEST(DoubleShufti, ExecMatchMixed2) {
onebyte.set('a');
twobyte.insert(make_pair('x', 'y'));
shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
char t2[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@@ -742,7 +838,8 @@ TEST(DoubleShufti, ExecMatchMixed3) {
onebyte.set('a');
twobyte.insert(make_pair('x', 'y'));
shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2);
bool rv = shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2);
ASSERT_TRUE(rv);
const int len = 420;
char t1[len + 1];