Skip to content

Commit e4ccdb9

Browse files
committed
Use Altivec as minimum ISA for Blake2s
1 parent 40bebb2 commit e4ccdb9

File tree

2 files changed

+12
-43
lines changed

2 files changed

+12
-43
lines changed

blake2.cpp

+5-24
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// implementation at http://github.com/BLAKE2/BLAKE2.
55
//
66
// The BLAKE2b and BLAKE2s numbers are consistent with the BLAKE2 team's
7-
// numbers. However, we have an Altivec/POWER7 implementation of BLAKE2s,
7+
// numbers. However, we have an Altivec implementation of BLAKE2s,
88
// and a POWER8 implementation of BLAKE2b (BLAKE2 team is missing them).
9-
// Altivec/POWER7 code is about 2x faster than C++ when using GCC 5.0 or
9+
// Altivec code is about 2x faster than C++ when using GCC 5.0 or
1010
// above. The POWER8 code is about 2.5x faster than C++ when using GCC 5.0
1111
// or above. If you use GCC 4.0 (PowerMac) or GCC 4.8 (GCC Compile Farm)
1212
// then the PowerPC code will be slower than C++. Be sure to use GCC 5.0
@@ -181,12 +181,6 @@ extern void BLAKE2_Compress32_NEON(const byte* input, BLAKE2s_State& state);
181181
extern void BLAKE2_Compress64_NEON(const byte* input, BLAKE2b_State& state);
182182
#endif
183183

184-
#if CRYPTOPP_POWER7_AVAILABLE
185-
extern void BLAKE2_Compress32_POWER7(const byte* input, BLAKE2s_State& state);
186-
#elif CRYPTOPP_ALTIVEC_AVAILABLE
187-
extern void BLAKE2_Compress32_ALTIVEC(const byte* input, BLAKE2s_State& state);
188-
#endif
189-
190184
#if CRYPTOPP_POWER8_AVAILABLE
191185
extern void BLAKE2_Compress64_POWER8(const byte* input, BLAKE2b_State& state);
192186
#endif
@@ -243,11 +237,7 @@ unsigned int BLAKE2s::OptimalDataAlignment() const
243237
return 4;
244238
else
245239
#endif
246-
#if (CRYPTOPP_POWER7_AVAILABLE)
247-
if (HasPower7())
248-
return 4;
249-
else
250-
#elif (CRYPTOPP_ALTIVEC_AVAILABLE)
240+
#if (CRYPTOPP_ALTIVEC_AVAILABLE)
251241
if (HasAltivec())
252242
return 16;
253243
else
@@ -267,11 +257,7 @@ std::string BLAKE2s::AlgorithmProvider() const
267257
return "NEON";
268258
else
269259
#endif
270-
#if (CRYPTOPP_POWER7_AVAILABLE)
271-
if (HasPower7())
272-
return "Power7";
273-
else
274-
#elif (CRYPTOPP_ALTIVEC_AVAILABLE)
260+
#if (CRYPTOPP_ALTIVEC_AVAILABLE)
275261
if (HasAltivec())
276262
return "Altivec";
277263
else
@@ -696,12 +682,7 @@ void BLAKE2s::Compress(const byte *input)
696682
return BLAKE2_Compress32_NEON(input, m_state);
697683
}
698684
#endif
699-
#if CRYPTOPP_POWER7_AVAILABLE
700-
if(HasPower7())
701-
{
702-
return BLAKE2_Compress32_POWER7(input, m_state);
703-
}
704-
#elif CRYPTOPP_ALTIVEC_AVAILABLE
685+
#if CRYPTOPP_ALTIVEC_AVAILABLE
705686
if(HasAltivec())
706687
{
707688
return BLAKE2_Compress32_ALTIVEC(input, m_state);

blake2s_simd.cpp

+7-19
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// appropriate instructions sets in some build configurations.
99

1010
// The BLAKE2b and BLAKE2s numbers are consistent with the BLAKE2 team's
11-
// numbers. However, we have an Altivec/POWER7 implementation of BLAKE2s,
12-
// and a POWER7 implementation of BLAKE2b (BLAKE2 is missing them). The
13-
// Altivec/POWER7 code is about 2x faster than C++ when using GCC 5.0 or
14-
// above. The POWER7 code is about 2.5x faster than C++ when using GCC 5.0
11+
// numbers. However, we have an Altivec implementation of BLAKE2s,
12+
// and a POWER8 implementation of BLAKE2b (BLAKE2 team is missing them).
13+
// Altivec code is about 2x faster than C++ when using GCC 5.0 or
14+
// above. The POWER8 code is about 2.5x faster than C++ when using GCC 5.0
1515
// or above. If you use GCC 4.0 (PowerMac) or GCC 4.8 (GCC Compile Farm)
1616
// then the PowerPC code will be slower than C++. Be sure to use GCC 5.0
1717
// or above for PowerPC builds or disable Altivec for BLAKE2b and BLAKE2s
@@ -697,7 +697,7 @@ void BLAKE2_Compress32_NEON(const byte* input, BLAKE2s_State& state)
697697
}
698698
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
699699

700-
#if (CRYPTOPP_POWER7_AVAILABLE || CRYPTOPP_ALTIVEC_AVAILABLE)
700+
#if (CRYPTOPP_ALTIVEC_AVAILABLE)
701701

702702
inline uint32x4_p VecLoad32(const void* p)
703703
{
@@ -868,11 +868,6 @@ uint32x4_p VectorSet32<3,1,3,1>(const uint32x4_p a, const uint32x4_p b,
868868
return VecPermute(a, c, mask);
869869
}
870870

871-
// BLAKE2_Compress32_CORE will use either POWER7 or ALTIVEC,
872-
// depending on the flags used to compile this source file. The
873-
// abstractions are handled in VecLoad, VecStore and friends. In
874-
// the future we may provide both POWER7 or ALTIVEC at the same
875-
// time to better support distros.
876871
void BLAKE2_Compress32_CORE(const byte* input, BLAKE2s_State& state)
877872
{
878873
# define m1 m0
@@ -1020,16 +1015,9 @@ void BLAKE2_Compress32_CORE(const byte* input, BLAKE2s_State& state)
10201015
VecStore32LE(state.h()+0, VecXor(ff0, VecXor(row1, row3)));
10211016
VecStore32LE(state.h()+4, VecXor(ff1, VecXor(row2, row4)));
10221017
}
1023-
#endif // CRYPTOPP_POWER7_AVAILABLE || CRYPTOPP_ALTIVEC_AVAILABLE
1024-
1025-
#if (CRYPTOPP_POWER7_AVAILABLE)
1018+
#endif // CRYPTOPP_ALTIVEC_AVAILABLE
10261019

1027-
void BLAKE2_Compress32_POWER7(const byte* input, BLAKE2s_State& state)
1028-
{
1029-
BLAKE2_Compress32_CORE(input, state);
1030-
}
1031-
1032-
#elif (CRYPTOPP_ALTIVEC_AVAILABLE)
1020+
#if (CRYPTOPP_ALTIVEC_AVAILABLE)
10331021

10341022
void BLAKE2_Compress32_ALTIVEC(const byte* input, BLAKE2s_State& state)
10351023
{

0 commit comments

Comments
 (0)