Add packed 32-bit Shuffle specializations for ChaCha on Power8

pull/730/head
Jeffrey Walton 2018-10-28 00:48:18 -04:00
parent 542140621a
commit a7615a8c7c
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 23 additions and 23 deletions

View File

@ -262,30 +262,30 @@ inline uint32x4_p RotateRight(const uint32x4_p val)
template <unsigned int S> template <unsigned int S>
inline uint32x4_p Shuffle(const uint32x4_p& val) inline uint32x4_p Shuffle(const uint32x4_p& val)
{ {
switch (S%4) CRYPTOPP_ASSERT(0);
{ return val;
case 1: }
template <>
inline uint32x4_p Shuffle<1>(const uint32x4_p& val)
{ {
const uint8x16_p mask = {4,5,6,7, 8,9,10,11, 12,13,14,15, 0,1,2,3}; const uint8x16_p mask = {4,5,6,7, 8,9,10,11, 12,13,14,15, 0,1,2,3};
return vec_perm(val, val, mask); return vec_perm(val, val, mask);
} }
case 2:
template <>
inline uint32x4_p Shuffle<2>(const uint32x4_p& val)
{ {
const uint8x16_p mask = {8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7}; const uint8x16_p mask = {8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7};
return vec_perm(val, val, mask); return vec_perm(val, val, mask);
} }
case 3:
template <>
inline uint32x4_p Shuffle<3>(const uint32x4_p& val)
{ {
const uint8x16_p mask = {12,13,14,15, 0,1,2,3, 4,5,6,7, 8,9,10,11}; const uint8x16_p mask = {12,13,14,15, 0,1,2,3, 4,5,6,7, 8,9,10,11};
return vec_perm(val, val, mask); return vec_perm(val, val, mask);
} }
default:
{
CRYPTOPP_ASSERT(0);
return val;
}
}
}
// Helper to perform 64-bit addition across two elements of 32-bit vectors // Helper to perform 64-bit addition across two elements of 32-bit vectors
inline uint32x4_p VectorAdd64(const uint32x4_p& a, const uint32x4_p& b) inline uint32x4_p VectorAdd64(const uint32x4_p& a, const uint32x4_p& b)