Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: third_party/zlib/crc_folding.c

Issue 552123005: Integrate SIMD optimisations for zlib (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gn build (uses different cflags -Wunused-variable) Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Compute the CRC32 using a parallelized folding approach with the PCLMULQDQ
3 * instruction.
4 *
5 * A white paper describing this algorithm can be found at:
6 * http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast -crc-computation-generic-polynomials-pclmulqdq-paper.pdf
7 *
8 * Copyright (C) 2013 Intel Corporation. All rights reserved.
9 * Authors:
10 * Wajdi Feghali <wajdi.k.feghali@intel.com>
11 * Jim Guilford <james.guilford@intel.com>
12 * Vinodh Gopal <vinodh.gopal@intel.com>
13 * Erdinc Ozturk <erdinc.ozturk@intel.com>
14 * Jim Kukunas <james.t.kukunas@linux.intel.com>
15 *
16 * For conditions of distribution and use, see copyright notice in zlib.h
17 */
18
19 #include "deflate.h"
20
21 #include <inttypes.h>
22 #include <immintrin.h>
23
24 #define CRC_LOAD(s) \
25 do { \
26 __m128i xmm_crc0 = _mm_loadu_si128((__m128i *)s->crc0 + 0);\
27 __m128i xmm_crc1 = _mm_loadu_si128((__m128i *)s->crc0 + 1);\
28 __m128i xmm_crc2 = _mm_loadu_si128((__m128i *)s->crc0 + 2);\
29 __m128i xmm_crc3 = _mm_loadu_si128((__m128i *)s->crc0 + 3);\
30 __m128i xmm_crc_part = _mm_loadu_si128((__m128i *)s->crc0 + 4);
31
32 #define CRC_SAVE(s) \
33 _mm_storeu_si128((__m128i *)s->crc0 + 0, xmm_crc0);\
34 _mm_storeu_si128((__m128i *)s->crc0 + 1, xmm_crc1);\
35 _mm_storeu_si128((__m128i *)s->crc0 + 2, xmm_crc2);\
36 _mm_storeu_si128((__m128i *)s->crc0 + 3, xmm_crc3);\
37 _mm_storeu_si128((__m128i *)s->crc0 + 4, xmm_crc_part);\
38 } while (0);
39
40 ZLIB_INTERNAL void crc_fold_init(deflate_state *const s)
41 {
42 CRC_LOAD(s)
43
44 xmm_crc0 = _mm_cvtsi32_si128(0x9db42487);
45 xmm_crc1 = _mm_setzero_si128();
46 xmm_crc2 = _mm_setzero_si128();
47 xmm_crc3 = _mm_setzero_si128();
48
49 CRC_SAVE(s)
50
51 s->strm->adler = 0;
52 }
53
54 local void fold_1(deflate_state *const s,
55 __m128i *xmm_crc0, __m128i *xmm_crc1,
56 __m128i *xmm_crc2, __m128i *xmm_crc3)
57 {
58 const __m128i xmm_fold4 = _mm_set_epi32(
59 0x00000001, 0x54442bd4,
60 0x00000001, 0xc6e41596);
61
62 __m128i x_tmp3;
63 __m128 ps_crc0, ps_crc3, ps_res;
64
65 x_tmp3 = *xmm_crc3;
66
67 *xmm_crc3 = *xmm_crc0;
68 *xmm_crc0 = _mm_clmulepi64_si128(*xmm_crc0, xmm_fold4, 0x01);
69 *xmm_crc3 = _mm_clmulepi64_si128(*xmm_crc3, xmm_fold4, 0x10);
70 ps_crc0 = _mm_castsi128_ps(*xmm_crc0);
71 ps_crc3 = _mm_castsi128_ps(*xmm_crc3);
72 ps_res = _mm_xor_ps(ps_crc0, ps_crc3);
73
74 *xmm_crc0 = *xmm_crc1;
75 *xmm_crc1 = *xmm_crc2;
76 *xmm_crc2 = x_tmp3;
77 *xmm_crc3 = _mm_castps_si128(ps_res);
78 }
79
80 local void fold_2(deflate_state *const s,
81 __m128i *xmm_crc0, __m128i *xmm_crc1,
82 __m128i *xmm_crc2, __m128i *xmm_crc3)
83 {
84 const __m128i xmm_fold4 = _mm_set_epi32(
85 0x00000001, 0x54442bd4,
86 0x00000001, 0xc6e41596);
87
88 __m128i x_tmp3, x_tmp2;
89 __m128 ps_crc0, ps_crc1, ps_crc2, ps_crc3, ps_res31, ps_res20;
90
91 x_tmp3 = *xmm_crc3;
92 x_tmp2 = *xmm_crc2;
93
94 *xmm_crc3 = *xmm_crc1;
95 *xmm_crc1 = _mm_clmulepi64_si128(*xmm_crc1, xmm_fold4, 0x01);
96 *xmm_crc3 = _mm_clmulepi64_si128(*xmm_crc3, xmm_fold4, 0x10);
97 ps_crc3 = _mm_castsi128_ps(*xmm_crc3);
98 ps_crc1 = _mm_castsi128_ps(*xmm_crc1);
99 ps_res31= _mm_xor_ps(ps_crc3, ps_crc1);
100
101 *xmm_crc2 = *xmm_crc0;
102 *xmm_crc0 = _mm_clmulepi64_si128(*xmm_crc0, xmm_fold4, 0x01);
103 *xmm_crc2 = _mm_clmulepi64_si128(*xmm_crc2, xmm_fold4, 0x10);
104 ps_crc0 = _mm_castsi128_ps(*xmm_crc0);
105 ps_crc2 = _mm_castsi128_ps(*xmm_crc2);
106 ps_res20= _mm_xor_ps(ps_crc0, ps_crc2);
107
108 *xmm_crc0 = x_tmp2;
109 *xmm_crc1 = x_tmp3;
110 *xmm_crc2 = _mm_castps_si128(ps_res20);
111 *xmm_crc3 = _mm_castps_si128(ps_res31);
112 }
113
114 local void fold_3(deflate_state *const s,
115 __m128i *xmm_crc0, __m128i *xmm_crc1,
116 __m128i *xmm_crc2, __m128i *xmm_crc3)
117 {
118 const __m128i xmm_fold4 = _mm_set_epi32(
119 0x00000001, 0x54442bd4,
120 0x00000001, 0xc6e41596);
121
122 __m128i x_tmp3;
123 __m128 ps_crc0, ps_crc1, ps_crc2, ps_crc3, ps_res32, ps_res21, ps_res10;
124
125 x_tmp3 = *xmm_crc3;
126
127 *xmm_crc3 = *xmm_crc2;
128 *xmm_crc2 = _mm_clmulepi64_si128(*xmm_crc2, xmm_fold4, 0x01);
129 *xmm_crc3 = _mm_clmulepi64_si128(*xmm_crc3, xmm_fold4, 0x10);
130 ps_crc2 = _mm_castsi128_ps(*xmm_crc2);
131 ps_crc3 = _mm_castsi128_ps(*xmm_crc3);
132 ps_res32 = _mm_xor_ps(ps_crc2, ps_crc3);
133
134 *xmm_crc2 = *xmm_crc1;
135 *xmm_crc1 = _mm_clmulepi64_si128(*xmm_crc1, xmm_fold4, 0x01);
136 *xmm_crc2 = _mm_clmulepi64_si128(*xmm_crc2, xmm_fold4, 0x10);
137 ps_crc1 = _mm_castsi128_ps(*xmm_crc1);
138 ps_crc2 = _mm_castsi128_ps(*xmm_crc2);
139 ps_res21= _mm_xor_ps(ps_crc1, ps_crc2);
140
141 *xmm_crc1 = *xmm_crc0;
142 *xmm_crc0 = _mm_clmulepi64_si128(*xmm_crc0, xmm_fold4, 0x01);
143 *xmm_crc1 = _mm_clmulepi64_si128(*xmm_crc1, xmm_fold4, 0x10);
144 ps_crc0 = _mm_castsi128_ps(*xmm_crc0);
145 ps_crc1 = _mm_castsi128_ps(*xmm_crc1);
146 ps_res10= _mm_xor_ps(ps_crc0, ps_crc1);
147
148 *xmm_crc0 = x_tmp3;
149 *xmm_crc1 = _mm_castps_si128(ps_res10);
150 *xmm_crc2 = _mm_castps_si128(ps_res21);
151 *xmm_crc3 = _mm_castps_si128(ps_res32);
152 }
153
154 local void fold_4(deflate_state *const s,
155 __m128i *xmm_crc0, __m128i *xmm_crc1,
156 __m128i *xmm_crc2, __m128i *xmm_crc3)
157 {
158 const __m128i xmm_fold4 = _mm_set_epi32(
159 0x00000001, 0x54442bd4,
160 0x00000001, 0xc6e41596);
161
162 __m128i x_tmp0, x_tmp1, x_tmp2, x_tmp3;
163 __m128 ps_crc0, ps_crc1, ps_crc2, ps_crc3;
164 __m128 ps_t0, ps_t1, ps_t2, ps_t3;
165 __m128 ps_res0, ps_res1, ps_res2, ps_res3;
166
167 x_tmp0 = *xmm_crc0;
168 x_tmp1 = *xmm_crc1;
169 x_tmp2 = *xmm_crc2;
170 x_tmp3 = *xmm_crc3;
171
172 *xmm_crc0 = _mm_clmulepi64_si128(*xmm_crc0, xmm_fold4, 0x01);
173 x_tmp0 = _mm_clmulepi64_si128(x_tmp0, xmm_fold4, 0x10);
174 ps_crc0 = _mm_castsi128_ps(*xmm_crc0);
175 ps_t0 = _mm_castsi128_ps(x_tmp0);
176 ps_res0 = _mm_xor_ps(ps_crc0, ps_t0);
177
178 *xmm_crc1 = _mm_clmulepi64_si128(*xmm_crc1, xmm_fold4, 0x01);
179 x_tmp1 = _mm_clmulepi64_si128(x_tmp1, xmm_fold4, 0x10);
180 ps_crc1 = _mm_castsi128_ps(*xmm_crc1);
181 ps_t1 = _mm_castsi128_ps(x_tmp1);
182 ps_res1 = _mm_xor_ps(ps_crc1, ps_t1);
183
184 *xmm_crc2 = _mm_clmulepi64_si128(*xmm_crc2, xmm_fold4, 0x01);
185 x_tmp2 = _mm_clmulepi64_si128(x_tmp2, xmm_fold4, 0x10);
186 ps_crc2 = _mm_castsi128_ps(*xmm_crc2);
187 ps_t2 = _mm_castsi128_ps(x_tmp2);
188 ps_res2 = _mm_xor_ps(ps_crc2, ps_t2);
189
190 *xmm_crc3 = _mm_clmulepi64_si128(*xmm_crc3, xmm_fold4, 0x01);
191 x_tmp3 = _mm_clmulepi64_si128(x_tmp3, xmm_fold4, 0x10);
192 ps_crc3 = _mm_castsi128_ps(*xmm_crc3);
193 ps_t3 = _mm_castsi128_ps(x_tmp3);
194 ps_res3 = _mm_xor_ps(ps_crc3, ps_t3);
195
196 *xmm_crc0 = _mm_castps_si128(ps_res0);
197 *xmm_crc1 = _mm_castps_si128(ps_res1);
198 *xmm_crc2 = _mm_castps_si128(ps_res2);
199 *xmm_crc3 = _mm_castps_si128(ps_res3);
200 }
201
202 local const unsigned __attribute__((aligned(32))) pshufb_shf_table[60] = {
203 0x84838281,0x88878685,0x8c8b8a89,0x008f8e8d, /* shl 15 (16 - 1)/shr1 */
204 0x85848382,0x89888786,0x8d8c8b8a,0x01008f8e, /* shl 14 (16 - 3)/shr2 */
205 0x86858483,0x8a898887,0x8e8d8c8b,0x0201008f, /* shl 13 (16 - 4)/shr3 */
206 0x87868584,0x8b8a8988,0x8f8e8d8c,0x03020100, /* shl 12 (16 - 4)/shr4 */
207 0x88878685,0x8c8b8a89,0x008f8e8d,0x04030201, /* shl 11 (16 - 5)/shr5 */
208 0x89888786,0x8d8c8b8a,0x01008f8e,0x05040302, /* shl 10 (16 - 6)/shr6 */
209 0x8a898887,0x8e8d8c8b,0x0201008f,0x06050403, /* shl 9 (16 - 7)/shr7 */
210 0x8b8a8988,0x8f8e8d8c,0x03020100,0x07060504, /* shl 8 (16 - 8)/shr8 */
211 0x8c8b8a89,0x008f8e8d,0x04030201,0x08070605, /* shl 7 (16 - 9)/shr9 */
212 0x8d8c8b8a,0x01008f8e,0x05040302,0x09080706, /* shl 6 (16 -10)/shr10*/
213 0x8e8d8c8b,0x0201008f,0x06050403,0x0a090807, /* shl 5 (16 -11)/shr11*/
214 0x8f8e8d8c,0x03020100,0x07060504,0x0b0a0908, /* shl 4 (16 -12)/shr12*/
215 0x008f8e8d,0x04030201,0x08070605,0x0c0b0a09, /* shl 3 (16 -13)/shr13*/
216 0x01008f8e,0x05040302,0x09080706,0x0d0c0b0a, /* shl 2 (16 -14)/shr14*/
217 0x0201008f,0x06050403,0x0a090807,0x0e0d0c0b /* shl 1 (16 -15)/shr15*/
218 };
219
220 local void partial_fold(deflate_state *const s, const size_t len,
221 __m128i *xmm_crc0, __m128i *xmm_crc1,
222 __m128i *xmm_crc2, __m128i *xmm_crc3,
223 __m128i *xmm_crc_part)
224 {
225
226 const __m128i xmm_fold4 = _mm_set_epi32(
227 0x00000001, 0x54442bd4,
228 0x00000001, 0xc6e41596);
229 const __m128i xmm_mask3 = _mm_set1_epi32(0x80808080);
230
231 __m128i xmm_shl, xmm_shr, xmm_tmp1, xmm_tmp2, xmm_tmp3;
232 __m128i xmm_a0_0, xmm_a0_1;
233 __m128 ps_crc3, psa0_0, psa0_1, ps_res;
234
235 xmm_shl = _mm_load_si128((__m128i *)pshufb_shf_table + (len - 1));
236 xmm_shr = xmm_shl;
237 xmm_shr = _mm_xor_si128(xmm_shr, xmm_mask3);
238
239 xmm_a0_0 = _mm_shuffle_epi8(*xmm_crc0, xmm_shl);
240
241 *xmm_crc0 = _mm_shuffle_epi8(*xmm_crc0, xmm_shr);
242 xmm_tmp1 = _mm_shuffle_epi8(*xmm_crc1, xmm_shl);
243 *xmm_crc0 = _mm_or_si128(*xmm_crc0, xmm_tmp1);
244
245 *xmm_crc1 = _mm_shuffle_epi8(*xmm_crc1, xmm_shr);
246 xmm_tmp2 = _mm_shuffle_epi8(*xmm_crc2, xmm_shl);
247 *xmm_crc1 = _mm_or_si128(*xmm_crc1, xmm_tmp2);
248
249 *xmm_crc2 = _mm_shuffle_epi8(*xmm_crc2, xmm_shr);
250 xmm_tmp3 = _mm_shuffle_epi8(*xmm_crc3, xmm_shl);
251 *xmm_crc2 = _mm_or_si128(*xmm_crc2, xmm_tmp3);
252
253 *xmm_crc3 = _mm_shuffle_epi8(*xmm_crc3, xmm_shr);
254 *xmm_crc_part = _mm_shuffle_epi8(*xmm_crc_part, xmm_shl);
255 *xmm_crc3 = _mm_or_si128(*xmm_crc3, *xmm_crc_part);
256
257 xmm_a0_1 = _mm_clmulepi64_si128(xmm_a0_0, xmm_fold4, 0x10);
258 xmm_a0_0 = _mm_clmulepi64_si128(xmm_a0_0, xmm_fold4, 0x01);
259
260 ps_crc3 = _mm_castsi128_ps(*xmm_crc3);
261 psa0_0 = _mm_castsi128_ps(xmm_a0_0);
262 psa0_1 = _mm_castsi128_ps(xmm_a0_1);
263
264 ps_res = _mm_xor_ps(ps_crc3, psa0_0);
265 ps_res = _mm_xor_ps(ps_res, psa0_1);
266
267 *xmm_crc3 = _mm_castps_si128(ps_res);
268 }
269
270 ZLIB_INTERNAL void crc_fold_copy(deflate_state *const s,
271 unsigned char *dst, const unsigned char *src, long len)
272 {
273 unsigned long algn_diff;
274 __m128i xmm_t0, xmm_t1, xmm_t2, xmm_t3;
275
276 CRC_LOAD(s)
277
278 if (len < 16) {
279 if (len == 0)
280 return;
281 xmm_crc_part = _mm_loadu_si128((__m128i *)src);
282 goto partial;
283 }
284
285 algn_diff = 0 - (unsigned long)src & 0xF;
286 if (algn_diff) {
287 xmm_crc_part = _mm_loadu_si128((__m128i *)src);
288 _mm_storeu_si128((__m128i *)dst, xmm_crc_part);
289
290 dst += algn_diff;
291 src += algn_diff;
292 len -= algn_diff;
293
294 partial_fold(s, algn_diff, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3,
295 &xmm_crc_part);
296 }
297
298 while ((len -= 64) >= 0) {
299 xmm_t0 = _mm_load_si128((__m128i *)src);
300 xmm_t1 = _mm_load_si128((__m128i *)src + 1);
301 xmm_t2 = _mm_load_si128((__m128i *)src + 2);
302 xmm_t3 = _mm_load_si128((__m128i *)src + 3);
303
304 fold_4(s, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3);
305
306 _mm_storeu_si128((__m128i *)dst, xmm_t0);
307 _mm_storeu_si128((__m128i *)dst + 1, xmm_t1);
308 _mm_storeu_si128((__m128i *)dst + 2, xmm_t2);
309 _mm_storeu_si128((__m128i *)dst + 3, xmm_t3);
310
311 xmm_crc0 = _mm_xor_si128(xmm_crc0, xmm_t0);
312 xmm_crc1 = _mm_xor_si128(xmm_crc1, xmm_t1);
313 xmm_crc2 = _mm_xor_si128(xmm_crc2, xmm_t2);
314 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_t3);
315
316 src += 64;
317 dst += 64;
318 }
319
320 /*
321 * len = num bytes left - 64
322 */
323 if (len + 16 >= 0) {
324 len += 16;
325
326 xmm_t0 = _mm_load_si128((__m128i *)src);
327 xmm_t1 = _mm_load_si128((__m128i *)src + 1);
328 xmm_t2 = _mm_load_si128((__m128i *)src + 2);
329
330 fold_3(s, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3);
331
332 _mm_storeu_si128((__m128i *)dst, xmm_t0);
333 _mm_storeu_si128((__m128i *)dst + 1, xmm_t1);
334 _mm_storeu_si128((__m128i *)dst + 2, xmm_t2);
335
336 xmm_crc1 = _mm_xor_si128(xmm_crc1, xmm_t0);
337 xmm_crc2 = _mm_xor_si128(xmm_crc2, xmm_t1);
338 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_t2);
339
340 if (len == 0)
341 goto done;
342
343 dst += 48;
344 xmm_crc_part = _mm_load_si128((__m128i *)src + 3);
345 } else if (len + 32 >= 0) {
346 len += 32;
347
348 xmm_t0 = _mm_load_si128((__m128i *)src);
349 xmm_t1 = _mm_load_si128((__m128i *)src + 1);
350
351 fold_2(s, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3);
352
353 _mm_storeu_si128((__m128i *)dst, xmm_t0);
354 _mm_storeu_si128((__m128i *)dst + 1, xmm_t1);
355
356 xmm_crc2 = _mm_xor_si128(xmm_crc2, xmm_t0);
357 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_t1);
358
359 if (len == 0)
360 goto done;
361
362 dst += 32;
363 xmm_crc_part = _mm_load_si128((__m128i *)src + 2);
364 } else if (len + 48 >= 0) {
365 len += 48;
366
367 xmm_t0 = _mm_load_si128((__m128i *)src);
368
369 fold_1(s, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3);
370
371 _mm_storeu_si128((__m128i *)dst, xmm_t0);
372
373 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_t0);
374
375 if (len == 0)
376 goto done;
377
378 dst += 16;
379 xmm_crc_part = _mm_load_si128((__m128i *)src + 1);
380 } else {
381 len += 64;
382 if (len == 0)
383 goto done;
384 xmm_crc_part = _mm_load_si128((__m128i *)src);
385 }
386
387 partial:
388 _mm_storeu_si128((__m128i *)dst, xmm_crc_part);
389 partial_fold(s, len, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3,
390 &xmm_crc_part);
391 done:
392 CRC_SAVE(s)
393 }
394
395 local const unsigned __attribute__((aligned(16))) crc_k[] = {
396 0xccaa009e, 0x00000000, /* rk1 */
397 0x751997d0, 0x00000001, /* rk2 */
398 0xccaa009e, 0x00000000, /* rk5 */
399 0x63cd6124, 0x00000001, /* rk6 */
400 0xf7011640, 0x00000001, /* rk7 */
401 0xdb710640, 0x00000001 /* rk8 */
402 };
403
404 local const unsigned __attribute__((aligned(16))) crc_mask[4] = {
405 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000
406 };
407
408 local const unsigned __attribute__((aligned(16))) crc_mask2[4] = {
409 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
410 };
411
412 unsigned ZLIB_INTERNAL crc_fold_512to32(deflate_state *const s)
413 {
414 const __m128i xmm_mask = _mm_load_si128((__m128i *)crc_mask);
415 const __m128i xmm_mask2 = _mm_load_si128((__m128i *)crc_mask2);
416
417 unsigned crc;
418 __m128i x_tmp0, x_tmp1, x_tmp2, crc_fold;
419
420 CRC_LOAD(s)
421
422 /*
423 * k1
424 */
425 crc_fold = _mm_load_si128((__m128i *)crc_k);
426
427 x_tmp0 = _mm_clmulepi64_si128(xmm_crc0, crc_fold, 0x10);
428 xmm_crc0 = _mm_clmulepi64_si128(xmm_crc0, crc_fold, 0x01);
429 xmm_crc1 = _mm_xor_si128(xmm_crc1, x_tmp0);
430 xmm_crc1 = _mm_xor_si128(xmm_crc1, xmm_crc0);
431
432 x_tmp1 = _mm_clmulepi64_si128(xmm_crc1, crc_fold, 0x10);
433 xmm_crc1 = _mm_clmulepi64_si128(xmm_crc1, crc_fold, 0x01);
434 xmm_crc2 = _mm_xor_si128(xmm_crc2, x_tmp1);
435 xmm_crc2 = _mm_xor_si128(xmm_crc2, xmm_crc1);
436
437 x_tmp2 = _mm_clmulepi64_si128(xmm_crc2, crc_fold, 0x10);
438 xmm_crc2 = _mm_clmulepi64_si128(xmm_crc2, crc_fold, 0x01);
439 xmm_crc3 = _mm_xor_si128(xmm_crc3, x_tmp2);
440 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_crc2);
441
442 /*
443 * k5
444 */
445 crc_fold = _mm_load_si128((__m128i *)crc_k + 1);
446
447 xmm_crc0 = xmm_crc3;
448 xmm_crc3 = _mm_clmulepi64_si128(xmm_crc3, crc_fold, 0);
449 xmm_crc0 = _mm_srli_si128(xmm_crc0, 8);
450 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_crc0);
451
452 xmm_crc0 = xmm_crc3;
453 xmm_crc3 = _mm_slli_si128(xmm_crc3, 4);
454 xmm_crc3 = _mm_clmulepi64_si128(xmm_crc3, crc_fold, 0x10);
455 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_crc0);
456 xmm_crc3 = _mm_and_si128(xmm_crc3, xmm_mask2);
457
458 /*
459 * k7
460 */
461 xmm_crc1 = xmm_crc3;
462 xmm_crc2 = xmm_crc3;
463 crc_fold = _mm_load_si128((__m128i *)crc_k + 2);
464
465 xmm_crc3 = _mm_clmulepi64_si128(xmm_crc3, crc_fold, 0);
466 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_crc2);
467 xmm_crc3 = _mm_and_si128(xmm_crc3, xmm_mask);
468
469 xmm_crc2 = xmm_crc3;
470 xmm_crc3 = _mm_clmulepi64_si128(xmm_crc3, crc_fold, 0x10);
471 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_crc2);
472 xmm_crc3 = _mm_xor_si128(xmm_crc3, xmm_crc1);
473
474 crc = _mm_extract_epi32(xmm_crc3, 2);
475 return ~crc;
476 CRC_SAVE(s)
477 }
OLDNEW
« no previous file with comments | « third_party/zlib/crc32.c ('k') | third_party/zlib/deflate.h » ('j') | third_party/zlib/deflate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698