Debian Codegraph @

crypto_encode/953xfreeze3/avx/encode.c

raw
1 // 20250302 djb: port to -Wc++-compat
2 #include <immintrin.h>
3 #include "crypto_encode.h"
4 #include "crypto_int16.h"
5 #define int16 crypto_int16
6
7 #define p 953
8
9 void crypto_encode(unsigned char *s,const void *v)
10 {
11 const int16 *r = (const int16 *) v;
12
13 int i = p-16;
14 for (;;) {
15 do {
16 __m256i x = _mm256_loadu_si256((__m256i *) r);
17 __m256i y = _mm256_mulhrs_epi16(x,_mm256_set1_epi16(10923));
18 x = _mm256_sub_epi16(x,y);
19 y = _mm256_add_epi16(y,y);
20 x = _mm256_sub_epi16(x,y);
21 __m128i x0 = _mm256_extractf128_si256(x,0);
22 __m128i x1 = _mm256_extractf128_si256(x,1);
23 _mm_storeu_si128((__m128i *) s,_mm_packs_epi16(x0,x1));
24 i -= 16;
25 r += 16;
26 s += 16;
27 } while (i >= 0);
28 if (i <= -16) break;
29 r += i;
30 s += i;
31 }
32 }