]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Two-way unrolling of aligned memxor3.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 23 Oct 2014 11:07:36 +0000 (13:07 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 23 Oct 2014 11:07:36 +0000 (13:07 +0200)
ChangeLog
memxor.c

index 8311fec98da612f2ac3f8ea06d2df5c732d2421e..8ecfb343e235e7e722f7bfa34acfd93e7ab49a02 100644 (file)
--- 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.
index e205aba85c5e1719955d43b69f9604b74ffed792..0e60e35d0a1ed43fc683a53fbfaf0f09391b4a75 100644 (file)
--- 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