Merge pull request #26222 from taosdata/fix/3_liaohj

fix(util): change the load of __m128i value.
This commit is contained in:
Haojun Liao 2024-06-20 21:26:57 +08:00 committed by GitHub
commit 079df11148
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 22 deletions

View File

@ -351,18 +351,18 @@ int32_t tsDecompressTimestampAvx2(const char *const input, const int32_t nelemen
int8_t nbytes1 = flags & INT8MASK(4); // range of nbytes starts from 0 to 7
int8_t nbytes2 = (flags >> 4) & INT8MASK(4);
__m128i data1;
if (nbytes1 == 0) {
data1 = _mm_setzero_si128();
} else {
memcpy(&data1, (const void*) (input + ipos), nbytes1);
__m128i data1 = _mm_setzero_si128();
if (nbytes1 > 0) {
int64_t tmp = 0;
memcpy(&tmp, (const void*) (input + ipos), nbytes1);
data1 = _mm_set1_epi64x(tmp);
}
__m128i data2;
if (nbytes2 == 0) {
data2 = _mm_setzero_si128();
} else {
memcpy(&data2, (const void*) (input + ipos + nbytes1), nbytes2);
__m128i data2 = _mm_setzero_si128();
if (nbytes2 > 0) {
int64_t tmp = 0;
memcpy(&tmp, (const void*) (input + ipos + nbytes1), nbytes2);
data2 = _mm_set1_epi64x(tmp);
}
data2 = _mm_broadcastq_epi64(data2);
@ -399,19 +399,15 @@ int32_t tsDecompressTimestampAvx2(const char *const input, const int32_t nelemen
int8_t nbytes1 = flags & INT8MASK(4); // range of nbytes starts from 0 to 7
int8_t nbytes2 = (flags >> 4) & INT8MASK(4);
__m128i data1;
if (nbytes1 == 0) {
data1 = _mm_setzero_si128();
} else {
__m128i data1 = _mm_setzero_si128();
if (nbytes1 > 0) {
int64_t dd = 0;
memcpy(&dd, (const void*) (input + ipos), nbytes1);
data1 = _mm_loadu_si64(&dd);
}
__m128i data2;
if (nbytes2 == 0) {
data2 = _mm_setzero_si128();
} else {
__m128i data2 = _mm_setzero_si128();
if (nbytes2 > 0) {
int64_t dd = 0;
memcpy(&dd, (const void*) (input + ipos + nbytes1), nbytes2);
data2 = _mm_loadu_si64(&dd);

View File

@ -38,13 +38,13 @@ TEST(utilTest, decompress_ts_test) {
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int64_t tsList[4] = {1286, 1124, 2681, 2823};
tsList[0] = 1286; tsList[1] = 1124; tsList[2]=2681; tsList[3] = 2823;
char* pOutput[4 * sizeof(int64_t)] = {0};
int32_t len = tsCompressTimestamp(tsList, sizeof(tsList), sizeof(tsList) / sizeof(tsList[0]), pOutput, 4,
// char* pOutput[4 * sizeof(int64_t)] = {0};
len = tsCompressTimestamp(tsList, sizeof(tsList), sizeof(tsList) / sizeof(tsList[0]), pOutput, 4,
ONE_STAGE_COMP, NULL, 0);
char* decompOutput[4 * 8] = {0};
decompOutput[4 * 8] = {0};
tsDecompressTimestamp(pOutput, len, 4, decompOutput, sizeof(int64_t) * 4, ONE_STAGE_COMP, NULL, 0);
for (int32_t i = 0; i < 4; ++i) {