AES optimization and aligned SSE allocators

This commit is contained in:
Jack Andersen 2015-07-26 14:17:35 -10:00 committed by Phillip Stephens
parent b38d7533c5
commit 43c317529c
2 changed files with 21 additions and 11 deletions

View File

@ -44,37 +44,54 @@ typedef unsigned long long atUint64;
// Vector types // Vector types
#if __SSE__ #if __SSE__
#include <xmmintrin.h> #include <xmmintrin.h>
#ifndef _WIN32
#include <mm_malloc.h>
#endif
#endif #endif
typedef union #include <new>
#define AT_ALIGNED_ALLOCATOR \
void* operator new(size_t bytes) noexcept \
{return _mm_malloc(bytes, 16);} \
void* operator new[](size_t bytes) noexcept \
{return _mm_malloc(bytes, 16);} \
void operator delete(void* buf) noexcept \
{_mm_free(buf);} \
void operator delete[](void* buf) noexcept \
{_mm_free(buf);} \
typedef union alignas(16)
{ {
#if __clang__ #if __clang__
float clangVec __attribute__((__vector_size__(8))); float clangVec __attribute__((__vector_size__(8)));
#endif #endif
#if __SSE__ #if __SSE__
__m128 mVec128; __m128 mVec128;
AT_ALIGNED_ALLOCATOR
#endif #endif
float vec[2]; float vec[2];
} atVec2f; } atVec2f;
typedef union typedef union alignas(16)
{ {
#if __clang__ #if __clang__
float clangVec __attribute__((__vector_size__(12))); float clangVec __attribute__((__vector_size__(12)));
#endif #endif
#if __SSE__ #if __SSE__
__m128 mVec128; __m128 mVec128;
AT_ALIGNED_ALLOCATOR
#endif #endif
float vec[3]; float vec[3];
} atVec3f; } atVec3f;
typedef union typedef union alignas(16)
{ {
#if __clang__ #if __clang__
float clangVec __attribute__((__vector_size__(16))); float clangVec __attribute__((__vector_size__(16)));
#endif #endif
#if __SSE__ #if __SSE__
__m128 mVec128; __m128 mVec128;
AT_ALIGNED_ALLOCATOR
#endif #endif
float vec[4]; float vec[4];
} atVec4f; } atVec4f;

View File

@ -39,14 +39,7 @@ static inline void unpack(uint32_t a, uint8_t* b)
static inline uint8_t xtime(uint8_t a) static inline uint8_t xtime(uint8_t a)
{ {
uint8_t b; return ((a << 1) ^ (((a>>7) & 1) * 0x11B));
if (a & 0x80) b = 0x1B;
else b = 0;
a <<= 1;
a ^= b;
return a;
} }
static const struct SoftwareAESTables static const struct SoftwareAESTables