Debian Codegraph @

cipher/blake2b-amd64-avx512.S

raw
1 /* blake2b-amd64-avx512.S - AVX512 implementation of BLAKE2b
2 *
3 * Copyright (C) 2022 Jussi Kivilinna <[email protected]>
4 *
5 * This file is part of Libgcrypt.
6 *
7 * Libgcrypt is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * Libgcrypt is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21 /* The code is based on public-domain/CC0 BLAKE2 reference implementation
22 * by Samual Neves, at https://github.com/BLAKE2/BLAKE2/tree/master/sse
23 * Copyright 2012, Samuel Neves <[email protected]>
24 */
25
26 #ifdef __x86_64
27 #include <config.h>
28 #if defined(HAVE_GCC_INLINE_ASM_AVX512) && \
29 (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \
30 defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS))
31
32 #include "asm-common-amd64.h"
33
34 /* register macros */
35 #define RSTATE %rdi
36 #define RINBLKS %rsi
37 #define RNBLKS %rdx
38 #define RIV %rcx
39
40 /* state structure */
41 #define STATE_H 0
42 #define STATE_T (STATE_H + 8 * 8)
43 #define STATE_F (STATE_T + 2 * 8)
44
45 /* vector registers */
46 #define ROW1 %ymm0
47 #define ROW2 %ymm1
48 #define ROW3 %ymm2
49 #define ROW4 %ymm3
50 #define TMP1 %ymm4
51 #define TMP1x %xmm4
52 #define R16 %ymm13
53
54 #define MA1 %ymm5
55 #define MA2 %ymm6
56 #define MA3 %ymm7
57 #define MA4 %ymm8
58 #define MA1x %xmm5
59 #define MA2x %xmm6
60 #define MA3x %xmm7
61 #define MA4x %xmm8
62
63 #define MB1 %ymm9
64 #define MB2 %ymm10
65 #define MB3 %ymm11
66 #define MB4 %ymm12
67 #define MB1x %xmm9
68 #define MB2x %xmm10
69 #define MB3x %xmm11
70 #define MB4x %xmm12
71
72 /**********************************************************************
73 blake2b/AVX2
74 **********************************************************************/
75
76 #define VPINSRQ_KMASK(kpos, qpos, mem, vreg) \
77 vmovdqu64 -((qpos) * 8) + mem, vreg {kpos}
78
79 #define GATHER_MSG(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
80 s0, s1, s2, s3, s4, s5, s6, s7, s8, \
81 s9, s10, s11, s12, s13, s14, s15) \
82 vmovq (s0)*8(RINBLKS), m1x; \
83 vmovq (s1)*8(RINBLKS), m2x; \
84 vmovq (s8)*8(RINBLKS), m3x; \
85 vmovq (s9)*8(RINBLKS), m4x; \
86 VPINSRQ_KMASK(%k1, 1, (s2)*8(RINBLKS), m1); \
87 VPINSRQ_KMASK(%k1, 1, (s3)*8(RINBLKS), m2); \
88 VPINSRQ_KMASK(%k1, 1, (s10)*8(RINBLKS), m3); \
89 VPINSRQ_KMASK(%k1, 1, (s11)*8(RINBLKS), m4); \
90 VPINSRQ_KMASK(%k2, 2, (s4)*8(RINBLKS), m1); \
91 VPINSRQ_KMASK(%k2, 2, (s5)*8(RINBLKS), m2); \
92 VPINSRQ_KMASK(%k2, 2, (s12)*8(RINBLKS), m3); \
93 VPINSRQ_KMASK(%k2, 2, (s13)*8(RINBLKS), m4); \
94 VPINSRQ_KMASK(%k3, 3, (s6)*8(RINBLKS), m1); \
95 VPINSRQ_KMASK(%k3, 3, (s7)*8(RINBLKS), m2); \
96 VPINSRQ_KMASK(%k3, 3, (s14)*8(RINBLKS), m3); \
97 VPINSRQ_KMASK(%k3, 3, (s15)*8(RINBLKS), m4);
98
99 #define GATHER_MSG_2(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
100 s0, s1, s2, s3, s4, s5, s6, s7, s8, \
101 s9, s10, s11, s12, s13, s14, s15) \
102 vmovdqu (s0)*8(RINBLKS), m1x; /* merged load */ \
103 vmovq (s1)*8(RINBLKS), m2x; \
104 vmovq (s8)*8(RINBLKS), m3x; \
105 vmovq (s9)*8(RINBLKS), m4x; \
106 VPINSRQ_KMASK(%k1, 1, (s3)*8(RINBLKS), m2); \
107 VPINSRQ_KMASK(%k1, 1, (s10)*8(RINBLKS), m3); \
108 VPINSRQ_KMASK(%k1, 1, (s11)*8(RINBLKS), m4); \
109 VPINSRQ_KMASK(%k2, 2, (s4)*8(RINBLKS), m1); \
110 VPINSRQ_KMASK(%k2, 2, (s5)*8(RINBLKS), m2); \
111 VPINSRQ_KMASK(%k2, 2, (s12)*8(RINBLKS), m3); \
112 VPINSRQ_KMASK(%k2, 2, (s13)*8(RINBLKS), m4); \
113 VPINSRQ_KMASK(%k3, 3, (s6)*8(RINBLKS), m1); \
114 VPINSRQ_KMASK(%k3, 3, (s7)*8(RINBLKS), m2); \
115 VPINSRQ_KMASK(%k3, 3, (s14)*8(RINBLKS), m3); \
116 VPINSRQ_KMASK(%k3, 3, (s15)*8(RINBLKS), m4);
117
118 #define GATHER_MSG_3(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
119 s0, s1, s2, s3, s4, s5, s6, s7, s8, \
120 s9, s10, s11, s12, s13, s14, s15) \
121 vmovq (s0)*8(RINBLKS), m1x; \
122 vmovq (s1)*8(RINBLKS), m2x; \
123 vmovdqu64 (s8)*8(RINBLKS), m3 {%k4}{z}; /* merged load */ \
124 vmovq (s9)*8(RINBLKS), m4x; \
125 VPINSRQ_KMASK(%k1, 1, (s2)*8(RINBLKS), m1); \
126 VPINSRQ_KMASK(%k1, 1, (s3)*8(RINBLKS), m2); \
127 VPINSRQ_KMASK(%k1, 1, (s10)*8(RINBLKS), m3); \
128 VPINSRQ_KMASK(%k1, 1, (s11)*8(RINBLKS), m4); \
129 VPINSRQ_KMASK(%k2, 2, (s4)*8(RINBLKS), m1); \
130 VPINSRQ_KMASK(%k2, 2, (s5)*8(RINBLKS), m2); \
131 VPINSRQ_KMASK(%k2, 2, (s13)*8(RINBLKS), m4); \
132 VPINSRQ_KMASK(%k3, 3, (s6)*8(RINBLKS), m1); \
133 VPINSRQ_KMASK(%k3, 3, (s7)*8(RINBLKS), m2); \
134 VPINSRQ_KMASK(%k3, 3, (s14)*8(RINBLKS), m3); \
135 VPINSRQ_KMASK(%k3, 3, (s15)*8(RINBLKS), m4);
136
137 #define GATHER_MSG_5(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
138 s0, s1, s2, s3, s4, s5, s6, s7, s8, \
139 s9, s10, s11, s12, s13, s14, s15) \
140 vmovq (s0)*8(RINBLKS), m1x; \
141 vmovq (s1)*8(RINBLKS), m2x; \
142 vmovq (s8)*8(RINBLKS), m3x; \
143 vmovq (s9)*8(RINBLKS), m4x; \
144 VPINSRQ_KMASK(%k5, 1, (s2)*8(RINBLKS), m1); /* merged load */ \
145 VPINSRQ_KMASK(%k6, 1, (s3)*8(RINBLKS), m2); /* merged load */ \
146 VPINSRQ_KMASK(%k1, 1, (s10)*8(RINBLKS), m3); \
147 VPINSRQ_KMASK(%k1, 1, (s11)*8(RINBLKS), m4); \
148 VPINSRQ_KMASK(%k2, 2, (s4)*8(RINBLKS), m1); \
149 VPINSRQ_KMASK(%k2, 2, (s12)*8(RINBLKS), m3); \
150 VPINSRQ_KMASK(%k2, 2, (s13)*8(RINBLKS), m4); \
151 VPINSRQ_KMASK(%k3, 3, (s7)*8(RINBLKS), m2); \
152 VPINSRQ_KMASK(%k3, 3, (s14)*8(RINBLKS), m3); \
153 VPINSRQ_KMASK(%k3, 3, (s15)*8(RINBLKS), m4);
154
155 #define GATHER_MSG_6(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
156 s0, s1, s2, s3, s4, s5, s6, s7, s8, \
157 s9, s10, s11, s12, s13, s14, s15) \
158 vmovdqu64 (s0)*8(RINBLKS), m1 {%k4}{z}; /* merged load */; \
159 vmovq (s1)*8(RINBLKS), m2x; \
160 vmovq (s8)*8(RINBLKS), m3x; \
161 vmovq (s9)*8(RINBLKS), m4x; \
162 VPINSRQ_KMASK(%k1, 1, (s2)*8(RINBLKS), m1); \
163 VPINSRQ_KMASK(%k1, 1, (s3)*8(RINBLKS), m2); \
164 VPINSRQ_KMASK(%k5, 1, (s10)*8(RINBLKS), m3); /* merged load */ \
165 VPINSRQ_KMASK(%k1, 1, (s11)*8(RINBLKS), m4); \
166 VPINSRQ_KMASK(%k2, 2, (s5)*8(RINBLKS), m2); \
167 VPINSRQ_KMASK(%k2, 2, (s12)*8(RINBLKS), m3); \
168 VPINSRQ_KMASK(%k2, 2, (s13)*8(RINBLKS), m4); \
169 VPINSRQ_KMASK(%k3, 3, (s6)*8(RINBLKS), m1); \
170 VPINSRQ_KMASK(%k3, 3, (s7)*8(RINBLKS), m2); \
171 VPINSRQ_KMASK(%k3, 3, (s15)*8(RINBLKS), m4);
172
173 #define GATHER_MSG_8(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
174 s0, s1, s2, s3, s4, s5, s6, s7, s8, \
175 s9, s10, s11, s12, s13, s14, s15) \
176 vmovq (s0)*8(RINBLKS), m1x; \
177 vmovq (s1)*8(RINBLKS), m2x; \
178 vmovdqu (s8)*8(RINBLKS), m3x; /* merged load */ \
179 vmovq (s9)*8(RINBLKS), m4x; \
180 VPINSRQ_KMASK(%k1, 1, (s2)*8(RINBLKS), m1); \
181 VPINSRQ_KMASK(%k1, 1, (s3)*8(RINBLKS), m2); \
182 VPINSRQ_KMASK(%k1, 1, (s11)*8(RINBLKS), m4); \
183 VPINSRQ_KMASK(%k2, 2, (s4)*8(RINBLKS), m1); \
184 VPINSRQ_KMASK(%k2, 2, (s5)*8(RINBLKS), m2); \
185 VPINSRQ_KMASK(%k2, 2, (s12)*8(RINBLKS), m3); \
186 vinserti64x2 $1, (s13)*8(RINBLKS), m4, m4; /* merged load */ \
187 VPINSRQ_KMASK(%k3, 3, (s6)*8(RINBLKS), m1); \
188 VPINSRQ_KMASK(%k3, 3, (s7)*8(RINBLKS), m2); \
189 VPINSRQ_KMASK(%k3, 3, (s14)*8(RINBLKS), m3);
190
191 #define GATHER_MSG_9(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
192 s0, s1, s2, s3, s4, s5, s6, s7, s8, \
193 s9, s10, s11, s12, s13, s14, s15) \
194 vmovq (s0)*8(RINBLKS), m1x; \
195 vmovdqu64 (s1)*8(RINBLKS), m2 {%k7}{z}; /* merged load */; \
196 vmovq (s8)*8(RINBLKS), m3x; \
197 vmovq (s9)*8(RINBLKS), m4x; \
198 VPINSRQ_KMASK(%k1, 1, (s2)*8(RINBLKS), m1); \
199 VPINSRQ_KMASK(%k1, 1, (s3)*8(RINBLKS), m2); \
200 VPINSRQ_KMASK(%k1, 1, (s10)*8(RINBLKS), m3); \
201 VPINSRQ_KMASK(%k1, 1, (s11)*8(RINBLKS), m4); \
202 VPINSRQ_KMASK(%k2, 2, (s4)*8(RINBLKS), m1); \
203 VPINSRQ_KMASK(%k2, 2, (s5)*8(RINBLKS), m2); \
204 VPINSRQ_KMASK(%k2, 2, (s12)*8(RINBLKS), m3); \
205 VPINSRQ_KMASK(%k2, 2, (s13)*8(RINBLKS), m4); \
206 VPINSRQ_KMASK(%k3, 3, (s6)*8(RINBLKS), m1); \
207 VPINSRQ_KMASK(%k3, 3, (s14)*8(RINBLKS), m3); \
208 VPINSRQ_KMASK(%k3, 3, (s15)*8(RINBLKS), m4);
209
210 #define LOAD_MSG_0(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
211 GATHER_MSG(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
212 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
213 #define LOAD_MSG_1(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
214 GATHER_MSG(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
215 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3)
216 #define LOAD_MSG_2(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
217 GATHER_MSG_2(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
218 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4)
219 #define LOAD_MSG_3(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
220 GATHER_MSG_3(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
221 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8)
222 #define LOAD_MSG_4(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
223 GATHER_MSG(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
224 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13)
225 #define LOAD_MSG_5(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
226 GATHER_MSG_5(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
227 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9)
228 #define LOAD_MSG_6(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
229 GATHER_MSG_6(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
230 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11)
231 #define LOAD_MSG_7(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
232 GATHER_MSG(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
233 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10)
234 #define LOAD_MSG_8(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
235 GATHER_MSG_8(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
236 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5)
237 #define LOAD_MSG_9(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
238 GATHER_MSG_9(m1, m2, m3, m4, m1x, m2x, m3x, m4x, \
239 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0)
240 #define LOAD_MSG_10(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
241 LOAD_MSG_0(m1, m2, m3, m4, m1x, m2x, m3x, m4x)
242 #define LOAD_MSG_11(m1, m2, m3, m4, m1x, m2x, m3x, m4x) \
243 LOAD_MSG_1(m1, m2, m3, m4, m1x, m2x, m3x, m4x)
244
245 #define LOAD_MSG(r, m1, m2, m3, m4) \
246 LOAD_MSG_##r(m1, m2, m3, m4, m1##x, m2##x, m3##x, m4##x)
247
248 #define ROR_32(in, out) vpshufd $0xb1, in, out
249
250 #define ROR_24(in, out) vprorq $24, in, out
251
252 #define ROR_16(in, out) vpshufb R16, in, out
253
254 #define ROR_63(in, out) vprorq $63, in, out
255
256 #define G(r1, r2, r3, r4, m, ROR_A, ROR_B) \
257 vpaddq m, r1, r1; \
258 vpaddq r2, r1, r1; \
259 vpxor r1, r4, r4; \
260 ROR_A(r4, r4); \
261 vpaddq r4, r3, r3; \
262 vpxor r3, r2, r2; \
263 ROR_B(r2, r2)
264
265 #define G1(r1, r2, r3, r4, m) \
266 G(r1, r2, r3, r4, m, ROR_32, ROR_24)
267
268 #define G2(r1, r2, r3, r4, m) \
269 G(r1, r2, r3, r4, m, ROR_16, ROR_63)
270
271 #define MM_SHUFFLE(z,y,x,w) \
272 (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
273
274 #define DIAGONALIZE(r1, r2, r3, r4) \
275 vpermq $MM_SHUFFLE(0,3,2,1), r2, r2; \
276 vpermq $MM_SHUFFLE(1,0,3,2), r3, r3; \
277 vpermq $MM_SHUFFLE(2,1,0,3), r4, r4
278
279 #define UNDIAGONALIZE(r1, r2, r3, r4) \
280 vpermq $MM_SHUFFLE(2,1,0,3), r2, r2; \
281 vpermq $MM_SHUFFLE(1,0,3,2), r3, r3; \
282 vpermq $MM_SHUFFLE(0,3,2,1), r4, r4
283
284 #define ROUND(r, m1, m2, m3, m4) \
285 G1(ROW1, ROW2, ROW3, ROW4, m1); \
286 G2(ROW1, ROW2, ROW3, ROW4, m2); \
287 DIAGONALIZE(ROW1, ROW2, ROW3, ROW4); \
288 G1(ROW1, ROW2, ROW3, ROW4, m3); \
289 G2(ROW1, ROW2, ROW3, ROW4, m4); \
290 UNDIAGONALIZE(ROW1, ROW2, ROW3, ROW4)
291
292 SECTION_RODATA
293
294 .align 32
295 ELF(.type _blake2b_avx512_data,@object;)
296 _blake2b_avx512_data:
297 .Liv:
298 .quad 0x6a09e667f3bcc908, 0xbb67ae8584caa73b
299 .quad 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1
300 .quad 0x510e527fade682d1, 0x9b05688c2b3e6c1f
301 .quad 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179
302 .Lshuf_ror16:
303 .byte 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9
304 .Lk1_mask:
305 .byte (1 << 1)
306 .Lk4_mask:
307 .byte (1 << 0) + (1 << 2)
308 .Lk5_mask:
309 .byte (1 << 1) + (1 << 3)
310 .Lk6_mask:
311 .byte (1 << 1) + (1 << 2)
312 .Lk7_mask:
313 .byte (1 << 0) + (1 << 3)
314
315 .text
316
317 .align 64
318 .globl _gcry_blake2b_transform_amd64_avx512
319 ELF(.type _gcry_blake2b_transform_amd64_avx512,@function;)
320
321 _gcry_blake2b_transform_amd64_avx512:
322 /* input:
323 * %rdi: state
324 * %rsi: blks
325 * %rdx: num_blks
326 */
327 CFI_STARTPROC();
328
329 spec_stop_avx512;
330
331 kmovb .Lk1_mask rRIP, %k1;
332 kshiftlb $1, %k1, %k2;
333 kshiftlb $2, %k1, %k3;
334 kmovb .Lk4_mask rRIP, %k4;
335 kmovb .Lk5_mask rRIP, %k5;
336 kmovb .Lk6_mask rRIP, %k6;
337 kmovb .Lk7_mask rRIP, %k7;
338
339 addq $128, (STATE_T + 0)(RSTATE);
340 adcq $0, (STATE_T + 8)(RSTATE);
341
342 vbroadcasti128 .Lshuf_ror16 rRIP, R16;
343
344 vmovdqa .Liv+(0 * 8) rRIP, ROW3;
345 vmovdqa .Liv+(4 * 8) rRIP, ROW4;
346
347 vmovdqu (STATE_H + 0 * 8)(RSTATE), ROW1;
348 vmovdqu (STATE_H + 4 * 8)(RSTATE), ROW2;
349
350 vpxor (STATE_T)(RSTATE), ROW4, ROW4;
351
352 LOAD_MSG(0, MA1, MA2, MA3, MA4);
353 LOAD_MSG(1, MB1, MB2, MB3, MB4);
354
355 .align 16
356 .Loop:
357 ROUND(0, MA1, MA2, MA3, MA4);
358 LOAD_MSG(2, MA1, MA2, MA3, MA4);
359 ROUND(1, MB1, MB2, MB3, MB4);
360 LOAD_MSG(3, MB1, MB2, MB3, MB4);
361 ROUND(2, MA1, MA2, MA3, MA4);
362 LOAD_MSG(4, MA1, MA2, MA3, MA4);
363 ROUND(3, MB1, MB2, MB3, MB4);
364 LOAD_MSG(5, MB1, MB2, MB3, MB4);
365 ROUND(4, MA1, MA2, MA3, MA4);
366 LOAD_MSG(6, MA1, MA2, MA3, MA4);
367 ROUND(5, MB1, MB2, MB3, MB4);
368 LOAD_MSG(7, MB1, MB2, MB3, MB4);
369 ROUND(6, MA1, MA2, MA3, MA4);
370 LOAD_MSG(8, MA1, MA2, MA3, MA4);
371 ROUND(7, MB1, MB2, MB3, MB4);
372 LOAD_MSG(9, MB1, MB2, MB3, MB4);
373 ROUND(8, MA1, MA2, MA3, MA4);
374 LOAD_MSG(10, MA1, MA2, MA3, MA4);
375 ROUND(9, MB1, MB2, MB3, MB4);
376 LOAD_MSG(11, MB1, MB2, MB3, MB4);
377 sub $1, RNBLKS;
378 jz .Loop_end;
379
380 lea 128(RINBLKS), RINBLKS;
381 addq $128, (STATE_T + 0)(RSTATE);
382 adcq $0, (STATE_T + 8)(RSTATE);
383
384 ROUND(10, MA1, MA2, MA3, MA4);
385 LOAD_MSG(0, MA1, MA2, MA3, MA4);
386 ROUND(11, MB1, MB2, MB3, MB4);
387 LOAD_MSG(1, MB1, MB2, MB3, MB4);
388
389 vpternlogq $0x96, (STATE_H + 0 * 8)(RSTATE), ROW3, ROW1;
390 vpternlogq $0x96, (STATE_H + 4 * 8)(RSTATE), ROW4, ROW2;
391
392 vmovdqa .Liv+(0 * 8) rRIP, ROW3;
393 vmovdqa .Liv+(4 * 8) rRIP, ROW4;
394
395 vmovdqu ROW1, (STATE_H + 0 * 8)(RSTATE);
396 vmovdqu ROW2, (STATE_H + 4 * 8)(RSTATE);
397
398 vpxor (STATE_T)(RSTATE), ROW4, ROW4;
399
400 jmp .Loop;
401
402 .align 16
403 .Loop_end:
404 ROUND(10, MA1, MA2, MA3, MA4);
405 ROUND(11, MB1, MB2, MB3, MB4);
406
407 vpternlogq $0x96, (STATE_H + 0 * 8)(RSTATE), ROW3, ROW1;
408 vpternlogq $0x96, (STATE_H + 4 * 8)(RSTATE), ROW4, ROW2;
409
410 vmovdqu ROW1, (STATE_H + 0 * 8)(RSTATE);
411 vmovdqu ROW2, (STATE_H + 4 * 8)(RSTATE);
412
413 xorl %eax, %eax;
414 kxord %k1, %k1, %k1;
415 kxord %k2, %k2, %k2;
416 kxord %k3, %k3, %k3;
417 kxord %k4, %k4, %k4;
418 kxord %k5, %k5, %k5;
419 kxord %k6, %k6, %k6;
420 kxord %k7, %k7, %k7;
421
422 vzeroall;
423 ret_spec_stop;
424 CFI_ENDPROC();
425 ELF(.size _gcry_blake2b_transform_amd64_avx512,
426 .-_gcry_blake2b_transform_amd64_avx512;)
427
428 #endif /*defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)*/
429 #endif /*__x86_64*/