diff --git a/gf2n.cpp b/gf2n.cpp index f7c7b8b5..92915da6 100644 --- a/gf2n.cpp +++ b/gf2n.cpp @@ -685,8 +685,6 @@ const GF2NT::Element& GF2NT::MultiplicativeInverse(const Element &a) const b[i] = b[i+1]; b[BitsToWords(m)-1] = 0; - // TODO: the shift by "t1+j" (64-bits) is being flagged as potential UB - // temp ^= ((temp >> j) & 1) << ((t1 + j) & (sizeof(temp)*8-1)); if (t1 < WORD_BITS) for (unsigned int j=0; j> j) & 1) << (t1 + j); const unsigned int shift = t1 + j; CRYPTOPP_ASSERT(shift < WORD_BITS); - temp ^= (CRYPTOPP_UNLIKELY(shift >= WORD_BITS) ? 0 : ((temp >> j) & 1) << shift); + temp ^= (shift < WORD_BITS) ? (((temp >> j) & 1) << shift) : 0; } else b[t1/WORD_BITS-1] ^= temp << t1%WORD_BITS; @@ -726,7 +724,7 @@ const GF2NT::Element& GF2NT::MultiplicativeInverse(const Element &a) const // temp ^= ((temp >> j) & 1) << (t1 + j); const unsigned int shift = t1 + j; CRYPTOPP_ASSERT(shift < WORD_BITS); - temp ^= (CRYPTOPP_UNLIKELY(shift >= WORD_BITS) ? 0 : ((temp >> j) & 1) << shift); + temp ^= (shift < WORD_BITS) ? (((temp >> j) & 1) << shift) : 0; } } else diff --git a/misc.h b/misc.h index 72d14be1..7a9cbd68 100644 --- a/misc.h +++ b/misc.h @@ -114,19 +114,6 @@ NAMESPACE_BEGIN(CryptoPP) // Forward declaration for IntToString specialization class Integer; -// ************** branch prediction *************** - -// Micro-optimization, use juditiously. Be sure you find a hotspot -// using 'make coverage', and its in a tight loop. Otherwise, DFW. -// Also see http://www.akkadia.org/drepper/cpumemory.pdf -#if defined(__GNUC__) -# define CRYPTOPP_LIKELY(x) __builtin_expect(!!(x), 1) -# define CRYPTOPP_UNLIKELY(x) __builtin_expect(!!(x), 0) -#else -# define CRYPTOPP_LIKELY(x) (x) -# define CRYPTOPP_UNLIKELY(x) (x) -#endif - // ************** compile-time assertion *************** #if CRYPTOPP_DOXYGEN_PROCESSING