aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/mem_ops.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-09-16 15:33:42 -0400
committerJack Lloyd <[email protected]>2017-09-16 15:33:42 -0400
commita191db93bcac4c5ce30936c5139daf76c5ac8c60 (patch)
treebe09688be19b0c91596f2ce8dc8b308b6f67f7b3 /src/lib/utils/mem_ops.cpp
parentab3fa2a93bec6b179041a33d93493a6beb647695 (diff)
Revert SIMDing of xor_buf in f39aa7bb
Forgot this causes all kinds of issues when the SIMD ISA is not part of the base instruction set (needing -maltivec, etc). It just happens to work on x86-64 because SSE2 is part of the base ISA there. Instead just unroll by 16x this seems to be enough that GCC figures it out.
Diffstat (limited to 'src/lib/utils/mem_ops.cpp')
-rw-r--r--src/lib/utils/mem_ops.cpp56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/lib/utils/mem_ops.cpp b/src/lib/utils/mem_ops.cpp
index 41a1bc547..a66d0928a 100644
--- a/src/lib/utils/mem_ops.cpp
+++ b/src/lib/utils/mem_ops.cpp
@@ -6,11 +6,6 @@
#include <botan/mem_ops.h>
-#if defined(BOTAN_HAS_SIMD_32)
- #include <botan/internal/simd_32.h>
- #include <botan/cpuid.h>
-#endif
-
namespace Botan {
bool constant_time_compare(const uint8_t x[],
@@ -29,30 +24,25 @@ void xor_buf(uint8_t x[],
const uint8_t y[],
size_t len)
{
-#if defined(BOTAN_HAS_SIMD_32)
- if(CPUID::has_simd_32())
- {
- while(len >= 16)
- {
- SIMD_32 x16 = SIMD_32::load_le(x);
- SIMD_32 y16 = SIMD_32::load_le(y);
- x16 ^= y16;
- x16.store_le(x);
-
- len -= 16;
- x += 16;
- y += 16;
- }
- }
-#endif
-
- while(len >= 8)
+ while(len >= 16)
{
- x[0] ^= y[0]; x[1] ^= y[1];
- x[2] ^= y[2]; x[3] ^= y[3];
- x[4] ^= y[4]; x[5] ^= y[5];
- x[6] ^= y[6]; x[7] ^= y[7];
- x += 8; y += 8; len -= 8;
+ x[0] ^= y[0];
+ x[1] ^= y[1];
+ x[2] ^= y[2];
+ x[3] ^= y[3];
+ x[4] ^= y[4];
+ x[5] ^= y[5];
+ x[6] ^= y[6];
+ x[7] ^= y[7];
+ x[8] ^= y[8];
+ x[9] ^= y[9];
+ x[10] ^= y[10];
+ x[11] ^= y[11];
+ x[12] ^= y[12];
+ x[13] ^= y[13];
+ x[14] ^= y[14];
+ x[15] ^= y[15];
+ x += 16; y += 16; len -= 16;
}
for(size_t i = 0; i != len; ++i)
@@ -76,7 +66,15 @@ void xor_buf(uint8_t out[],
out[5] = in[5] ^ in2[5];
out[6] = in[6] ^ in2[6];
out[7] = in[7] ^ in2[7];
- in += 8; in2 += 8; out += 8; length -= 8;
+ out[8] = in[8] ^ in2[8];
+ out[9] = in[9] ^ in2[9];
+ out[10] = in[10] ^ in2[10];
+ out[11] = in[11] ^ in2[11];
+ out[12] = in[12] ^ in2[12];
+ out[13] = in[13] ^ in2[13];
+ out[14] = in[14] ^ in2[14];
+ out[15] = in[15] ^ in2[15];
+ in += 16; in2 += 16; out += 16; length -= 16;
}
for(size_t i = 0; i != length; ++i)