Using _mm_add_epi8(a, a) is cleaner than the shift+mask

This commit is contained in:
Frank Denis
2025-12-30 09:52:00 +01:00
parent 53f73b51e4
commit 93d8f8eefe
+2 -4
View File
@@ -317,10 +317,8 @@ static void
pfx_shift_left(uint8_t ip16[16])
{
BlockVec v = LOAD128(ip16);
const BlockVec mask_fe = _mm_set1_epi8((char) 0xfe);
const BlockVec mask_01 = _mm_set1_epi8(0x01);
const BlockVec shl = _mm_and_si128(_mm_slli_epi16(v, 1), mask_fe);
const BlockVec msb = _mm_and_si128(_mm_srli_epi16(v, 7), mask_01);
const BlockVec shl = _mm_add_epi8(v, v);
const BlockVec msb = _mm_and_si128(_mm_srli_epi16(v, 7), _mm_set1_epi8(0x01));
const BlockVec carries = _mm_srli_si128(msb, 1);
v = _mm_or_si128(shl, carries);
STORE128(ip16, v);