Skip to content

Commit 847cb7e

Browse files
jkivilinherbertx
authored andcommitted
crypto: serpent-sse2 - change transpose_4x4 to only use integer instructions
Matrix transpose macro in serpent-sse2 uses mix of SSE2 integer and SSE floating point instructions, which might cause performance penality on some CPUs. This patch replaces transpose_4x4 macro with version that uses only SSE2 integer instructions. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 4c58464 commit 847cb7e

2 files changed

Lines changed: 26 additions & 32 deletions

File tree

‎arch/x86/crypto/serpent-sse2-i586-asm_32.S‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -463,23 +463,20 @@
463463
pand x0, x4; \
464464
pxor x2, x4;
465465

466-
#define transpose_4x4(x0, x1, x2, x3, t1, t2, t3) \
467-
movdqa x2, t3; \
468-
movdqa x0, t1; \
469-
unpcklps x3, t3; \
466+
#define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
470467
movdqa x0, t2; \
471-
unpcklps x1, t1; \
472-
unpckhps x1, t2; \
473-
movdqa t3, x1; \
474-
unpckhps x3, x2; \
475-
movdqa t1, x0; \
476-
movhlps t1, x1; \
477-
movdqa t2, t1; \
478-
movlhps t3, x0; \
479-
movlhps x2, t1; \
480-
movhlps t2, x2; \
481-
movdqa x2, x3; \
482-
movdqa t1, x2;
468+
punpckldq x1, x0; \
469+
punpckhdq x1, t2; \
470+
movdqa x2, t1; \
471+
punpckhdq x3, x2; \
472+
punpckldq x3, t1; \
473+
movdqa x0, x1; \
474+
punpcklqdq t1, x0; \
475+
punpckhqdq t1, x1; \
476+
movdqa t2, x3; \
477+
punpcklqdq x2, t2; \
478+
punpckhqdq x2, x3; \
479+
movdqa t2, x2;
483480

484481
#define read_blocks(in, x0, x1, x2, x3, t0, t1, t2) \
485482
movdqu (0*4*4)(in), x0; \

‎arch/x86/crypto/serpent-sse2-x86_64-asm_64.S‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -585,23 +585,20 @@
585585
get_key(i, 1, RK1); \
586586
SBOX ## _2(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, x4 ## 2); \
587587

588-
#define transpose_4x4(x0, x1, x2, x3, t1, t2, t3) \
589-
movdqa x2, t3; \
590-
movdqa x0, t1; \
591-
unpcklps x3, t3; \
588+
#define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
592589
movdqa x0, t2; \
593-
unpcklps x1, t1; \
594-
unpckhps x1, t2; \
595-
movdqa t3, x1; \
596-
unpckhps x3, x2; \
597-
movdqa t1, x0; \
598-
movhlps t1, x1; \
599-
movdqa t2, t1; \
600-
movlhps t3, x0; \
601-
movlhps x2, t1; \
602-
movhlps t2, x2; \
603-
movdqa x2, x3; \
604-
movdqa t1, x2;
590+
punpckldq x1, x0; \
591+
punpckhdq x1, t2; \
592+
movdqa x2, t1; \
593+
punpckhdq x3, x2; \
594+
punpckldq x3, t1; \
595+
movdqa x0, x1; \
596+
punpcklqdq t1, x0; \
597+
punpckhqdq t1, x1; \
598+
movdqa t2, x3; \
599+
punpcklqdq x2, t2; \
600+
punpckhqdq x2, x3; \
601+
movdqa t2, x2;
605602

606603
#define read_blocks(in, x0, x1, x2, x3, t0, t1, t2) \
607604
movdqu (0*4*4)(in), x0; \

0 commit comments

Comments
 (0)