-
Notifications
You must be signed in to change notification settings - Fork 1
/
arch-x86-slide_sse.c
46 lines (39 loc) · 1.05 KB
/
arch-x86-slide_sse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* SSE optimized hash slide
*
* Copyright (C) 2017 Intel Corporation
* Authors:
* Arjan van de Ven <arjan@linux.intel.com>
* Jim Kukunas <james.t.kukunas@linux.intel.com>
*
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zbuild.h"
#include "deflate.h"
#include <immintrin.h>
ZLIB_INTERNAL void slide_hash_sse2(deflate_state *s) {
Pos *p;
unsigned n;
unsigned wsize = s->w_size;
const __m128i xmm_wsize = _mm_set1_epi16(s->w_size);
n = s->hash_size;
p = &s->head[n] - 8;
do {
__m128i value, result;
value = _mm_loadu_si128((__m128i *)p);
result= _mm_subs_epu16(value, xmm_wsize);
_mm_storeu_si128((__m128i *)p, result);
p -= 8;
n -= 8;
} while (n > 0);
n = wsize;
p = &s->prev[n] - 8;
do {
__m128i value, result;
value = _mm_loadu_si128((__m128i *)p);
result= _mm_subs_epu16(value, xmm_wsize);
_mm_storeu_si128((__m128i *)p, result);
p -= 8;
n -= 8;
} while (n > 0);
}