From 5ce02c323b1102c1e603754be5b492d238ee3af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Thu, 23 Oct 2014 13:07:36 +0200 Subject: [PATCH] Two-way unrolling of aligned memxor3. --- ChangeLog | 1 + memxor.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8311fec9..8ecfb343 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * memxor.c (memxor_common_alignment, memxor_different_alignment) (memxor): Change loop order, iterate from the end. + (memxor3_common_alignment): Unroll twice. * examples/nettle-benchmark.c (time_memxor): Allocate buffers as arrays of unsigned long, for more reliable alignment. diff --git a/memxor.c b/memxor.c index e205aba8..0e60e35d 100644 --- a/memxor.c +++ b/memxor.c @@ -166,8 +166,17 @@ memxor3_common_alignment (word_t *dst, const word_t *a, const word_t *b, size_t n) { /* FIXME: Require n > 0? */ - while (n-- > 0) - dst[n] = a[n] ^ b[n]; + if (n & 1) + { + n--; + dst[n] = a[n] ^ b[n]; + } + while (n > 0) + { + n -= 2; + dst[n+1] = a[n+1] ^ b[n+1]; + dst[n] = a[n] ^ b[n]; + } } static void -- GitLab