• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* chunkset_sse.c -- SSE inline functions to copy small data chunks.
2  * For conditions of distribution and use, see copyright notice in zlib.h
3  */
4 
5 #include "zbuild.h"
6 #include "zutil.h"
7 
8 #ifdef X86_SSE2
9 #include <immintrin.h>
10 
11 typedef __m128i chunk_t;
12 
13 #define HAVE_CHUNKMEMSET_1
14 #define HAVE_CHUNKMEMSET_2
15 #define HAVE_CHUNKMEMSET_4
16 #define HAVE_CHUNKMEMSET_8
17 
chunkmemset_1(uint8_t * from,chunk_t * chunk)18 static inline void chunkmemset_1(uint8_t *from, chunk_t *chunk) {
19     *chunk = _mm_set1_epi8(*(int8_t *)from);
20 }
21 
chunkmemset_2(uint8_t * from,chunk_t * chunk)22 static inline void chunkmemset_2(uint8_t *from, chunk_t *chunk) {
23     *chunk = _mm_set1_epi16(*(int16_t *)from);
24 }
25 
chunkmemset_4(uint8_t * from,chunk_t * chunk)26 static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) {
27     *chunk = _mm_set1_epi32(*(int32_t *)from);
28 }
29 
chunkmemset_8(uint8_t * from,chunk_t * chunk)30 static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) {
31     *chunk = _mm_set1_epi64x(*(int64_t *)from);
32 }
33 
loadchunk(uint8_t const * s,chunk_t * chunk)34 static inline void loadchunk(uint8_t const *s, chunk_t *chunk) {
35     *chunk = _mm_loadu_si128((__m128i *)s);
36 }
37 
storechunk(uint8_t * out,chunk_t * chunk)38 static inline void storechunk(uint8_t *out, chunk_t *chunk) {
39     _mm_storeu_si128((__m128i *)out, *chunk);
40 }
41 
42 #define CHUNKSIZE        chunksize_sse2
43 #define CHUNKCOPY        chunkcopy_sse2
44 #define CHUNKCOPY_SAFE   chunkcopy_safe_sse2
45 #define CHUNKUNROLL      chunkunroll_sse2
46 #define CHUNKMEMSET      chunkmemset_sse2
47 #define CHUNKMEMSET_SAFE chunkmemset_safe_sse2
48 
49 #include "chunkset_tpl.h"
50 
51 #endif
52