Mailing List Archive

[PATCH 1/4] gostr3411-94: small speedup
From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

* cipher/gostr3411-94.c (do_p): unroll loop for a small spedup
--

Before:
GOSTR3411_94 | 25.12 ns/B 37.96 MiB/s - c/B
GOSTR3411_CP | 25.14 ns/B 37.93 MiB/s - c/B
After:
GOSTR3411_94 | 24.57 ns/B 38.81 MiB/s - c/B
GOSTR3411_CP | 24.59 ns/B 38.79 MiB/s - c/B

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
cipher/gostr3411-94.c | 50 +++++++++++++++++++++++++++++++++----------
1 file changed, 39 insertions(+), 11 deletions(-)

diff --git a/cipher/gostr3411-94.c b/cipher/gostr3411-94.c
index ebf9e0a242f3..c5a0aef63de3 100644
--- a/cipher/gostr3411-94.c
+++ b/cipher/gostr3411-94.c
@@ -83,17 +83,45 @@ do_p (u32 *p, u32 *u, u32 *v)
for (k = 0; k < 8; k++)
t[k] = u[k] ^ v[k];

- for (k = 0; k < 4; k++)
- {
- p[k+0] = ((t[0] >> (8*k)) & 0xff) << 0 |
- ((t[2] >> (8*k)) & 0xff) << 8 |
- ((t[4] >> (8*k)) & 0xff) << 16 |
- ((t[6] >> (8*k)) & 0xff) << 24;
- p[k+4] = ((t[1] >> (8*k)) & 0xff) << 0 |
- ((t[3] >> (8*k)) & 0xff) << 8 |
- ((t[5] >> (8*k)) & 0xff) << 16 |
- ((t[7] >> (8*k)) & 0xff) << 24;
- }
+ k = 0;
+ p[k+0] = ((t[0] >> (8*k)) & 0xff) << 0 |
+ ((t[2] >> (8*k)) & 0xff) << 8 |
+ ((t[4] >> (8*k)) & 0xff) << 16 |
+ ((t[6] >> (8*k)) & 0xff) << 24;
+ p[k+4] = ((t[1] >> (8*k)) & 0xff) << 0 |
+ ((t[3] >> (8*k)) & 0xff) << 8 |
+ ((t[5] >> (8*k)) & 0xff) << 16 |
+ ((t[7] >> (8*k)) & 0xff) << 24;
+
+ k = 1;
+ p[k+0] = ((t[0] >> (8*k)) & 0xff) << 0 |
+ ((t[2] >> (8*k)) & 0xff) << 8 |
+ ((t[4] >> (8*k)) & 0xff) << 16 |
+ ((t[6] >> (8*k)) & 0xff) << 24;
+ p[k+4] = ((t[1] >> (8*k)) & 0xff) << 0 |
+ ((t[3] >> (8*k)) & 0xff) << 8 |
+ ((t[5] >> (8*k)) & 0xff) << 16 |
+ ((t[7] >> (8*k)) & 0xff) << 24;
+
+ k = 2;
+ p[k+0] = ((t[0] >> (8*k)) & 0xff) << 0 |
+ ((t[2] >> (8*k)) & 0xff) << 8 |
+ ((t[4] >> (8*k)) & 0xff) << 16 |
+ ((t[6] >> (8*k)) & 0xff) << 24;
+ p[k+4] = ((t[1] >> (8*k)) & 0xff) << 0 |
+ ((t[3] >> (8*k)) & 0xff) << 8 |
+ ((t[5] >> (8*k)) & 0xff) << 16 |
+ ((t[7] >> (8*k)) & 0xff) << 24;
+
+ k = 3;
+ p[k+0] = ((t[0] >> (8*k)) & 0xff) << 0 |
+ ((t[2] >> (8*k)) & 0xff) << 8 |
+ ((t[4] >> (8*k)) & 0xff) << 16 |
+ ((t[6] >> (8*k)) & 0xff) << 24;
+ p[k+4] = ((t[1] >> (8*k)) & 0xff) << 0 |
+ ((t[3] >> (8*k)) & 0xff) << 8 |
+ ((t[5] >> (8*k)) & 0xff) << 16 |
+ ((t[7] >> (8*k)) & 0xff) << 24;
}

static void
--
2.24.0


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: [PATCH 1/4] gostr3411-94: small speedup [ In reply to ]
Hello,

??, 12 ????. 2019 ?. ? 16:50, <dbaryshkov@gmail.com>:
>
> From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>
> * cipher/gostr3411-94.c (do_p): unroll loop for a small spedup

What about these patches? They bring in small speedups and also serve
as a foundation for next few patches adding counter and MAC modes (rfc
5830), key meshing (rfc 4357) and Magma cipher (draft-dolmatov-magma).

--
With best wishes
Dmitry

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: [PATCH 1/4] gostr3411-94: small speedup [ In reply to ]
Hello,

On 20.11.2019 11.18, Dmitry Eremin-Solenikov via Gcrypt-devel wrote:
> Hello,
>
> ??, 12 ????. 2019 ?. ? 16:50, <dbaryshkov@gmail.com>:
>>
>> From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>>
>> * cipher/gostr3411-94.c (do_p): unroll loop for a small spedup
>
> What about these patches? They bring in small speedups and also serve
> as a foundation for next few patches adding counter and MAC modes (rfc
> 5830), key meshing (rfc 4357) and Magma cipher (draft-dolmatov-magma).
>

Patches tested and applied. Thanks.

-Jussi

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel