X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/1da1ed6a5815deef6c33d74f1eb3c856793df3e5..a13b573023a59dc1e2febef1142aa4b1d1af67b7:/symm/chacha-x86ish-sse2.S diff --git a/symm/chacha-x86ish-sse2.S b/symm/chacha-x86ish-sse2.S index f36bf90f..a7ff68b5 100644 --- a/symm/chacha-x86ish-sse2.S +++ b/symm/chacha-x86ish-sse2.S @@ -31,18 +31,10 @@ #include "asm-common.h" ///-------------------------------------------------------------------------- -/// Local utilities. - -// Magic constants for shuffling. -#define ROTL 0x93 -#define ROT2 0x4e -#define ROTR 0x39 - -///-------------------------------------------------------------------------- /// Main code. .arch pentium4 - .section .text + .text FUNC(chacha_core_x86ish_sse2) @@ -110,6 +102,8 @@ FUNC(chacha_core_x86ish_sse2) # define SAVE3 [rsp + 32] sub rsp, 48 + 8 + .seh_stackalloc 48 + 8 + .seh_endprologue #endif // First job is to slurp the matrix into XMM registers. Be careful: @@ -131,7 +125,7 @@ FUNC(chacha_core_x86ish_sse2) movdqa SAVE2, xmm2 movdqa SAVE3, xmm3 -loop: +0: // Apply a column quarterround to each of the columns simultaneously. // Alas, there doesn't seem to be a packed doubleword rotate, so we // have to synthesize it. @@ -162,9 +156,9 @@ loop: // c += d; b ^= c; b <<<= 7 paddd xmm2, xmm3 - pshufd xmm3, xmm3, ROTL + pshufd xmm3, xmm3, SHUF(2, 1, 0, 3) pxor xmm1, xmm2 - pshufd xmm2, xmm2, ROT2 + pshufd xmm2, xmm2, SHUF(1, 0, 3, 2) movdqa xmm4, xmm1 pslld xmm1, 7 psrld xmm4, 25 @@ -182,7 +176,7 @@ loop: // // The shuffles have quite high latency, so they've mostly been // pushed upwards. The remaining one can't be moved, though. - pshufd xmm1, xmm1, ROTR + pshufd xmm1, xmm1, SHUF(0, 3, 2, 1) // Apply the diagonal quarterround to each of the columns // simultaneously. @@ -213,9 +207,9 @@ loop: // c += d; b ^= c; b <<<= 7 paddd xmm2, xmm3 - pshufd xmm3, xmm3, ROTR + pshufd xmm3, xmm3, SHUF(0, 3, 2, 1) pxor xmm1, xmm2 - pshufd xmm2, xmm2, ROT2 + pshufd xmm2, xmm2, SHUF(1, 0, 3, 2) movdqa xmm4, xmm1 pslld xmm1, 7 psrld xmm4, 25 @@ -224,11 +218,11 @@ loop: // Finally, finish off undoing the transpose, and we're done for this // doubleround. Again, most of this was done above so we don't have // to wait for the shuffles. - pshufd xmm1, xmm1, ROTL + pshufd xmm1, xmm1, SHUF(2, 1, 0, 3) // Decrement the loop counter and see if we should go round again. sub NR, 2 - ja loop + ja 0b // Almost there. Firstly, the feedforward addition. paddd xmm0, SAVE0