Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Optimize Maj() computation in 4way

Instead of computing Maj(a, b, c) as (a & b) ^ (a & c) ^ (b & c),
compute it instead as (a & (b ^ c)) ^ (b & c) to reduce the number of
operations.
  • Loading branch information...
commit 0b625aa569d9b4bafb41787d3db20e54fd3fe4da 1 parent 30889d0
@verement verement authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  sha256_4way.c
View
2  sha256_4way.c
@@ -45,7 +45,7 @@ static inline __m128i Ch(const __m128i b, const __m128i c, const __m128i d) {
}
static inline __m128i Maj(const __m128i b, const __m128i c, const __m128i d) {
- return _mm_xor_si128(_mm_xor_si128(_mm_and_si128(b,c),_mm_and_si128(b,d)),_mm_and_si128(c,d));
+ return _mm_xor_si128(_mm_and_si128(b,_mm_xor_si128(c,d)),_mm_and_si128(c,d));
}
static __attribute__((always_inline)) __m128i ROTR(__m128i x, const int n) {
Please sign in to comment.
Something went wrong with that request. Please try again.