Skip to content

Commit 709c119

Browse files
committed
Faster TWEAK_EXPAND with unaligned tweak
1 parent f7bbc23 commit 709c119

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/ipcrypt2.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,12 @@ typedef __m128i BlockVec;
232232
/**
233233
* Expand an 8-byte tweak into a 128-bit register.
234234
*/
235-
# define TWEAK_EXPAND(tweak) \
236-
_mm_set_epi8(0, 0, tweak[7], tweak[6], 0, 0, tweak[5], tweak[4], 0, 0, tweak[3], tweak[2], \
237-
0, 0, tweak[1], tweak[0])
235+
# define TWEAK_EXPAND(tweak) \
236+
_mm_shuffle_epi8(_mm_loadu_si64((const void *) tweak), \
237+
_mm_setr_epi8(0, 1, (char) 0x80, (char) 0x80, 2, 3, (char) 0x80, \
238+
(char) 0x80, 4, 5, (char) 0x80, (char) 0x80, 6, 7, \
239+
(char) 0x80, (char) 0x80))
240+
238241
#else
239242
# error This architecture is not supported yet
240243
#endif

0 commit comments

Comments
 (0)