mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Using _mm_add_epi8(a, a) is cleaner than the shift+mask
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user