Skip to content

Commit

Permalink
Update InvNTT docs (intel#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
fboemer authored Nov 11, 2021
1 parent 18a10b1 commit a6bb385
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hexl/ntt/inv-ntt-avx512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@ template void InverseTransformFromBitReverseAVX512<NTT::s_default_shift_bits>(
template <int BitShift, bool InputLessThanMod>
inline void InvButterfly(__m512i* X, __m512i* Y, __m512i W, __m512i W_precon,
__m512i neg_modulus, __m512i twice_modulus) {
// Compute T first to allow in-place update of X
__m512i Y_minus_2q = _mm512_sub_epi64(*Y, twice_modulus);
__m512i T = _mm512_sub_epi64(*X, Y_minus_2q);

if (InputLessThanMod) {
// No need for modulus reduction, since inputs are in [0, q)
*X = _mm512_add_epi64(*X, *Y);
} else {
// Algorithm 3 computes (X >= 2q) ? (X - 2q) : X
// We instead compute (X - 2q >= 0) ? (X - 2q) : X
// This allows us to use the faster _mm512_movepi64_mask rather than
// _mm512_cmp_epu64_mask to create the mask.
*X = _mm512_add_epi64(*X, Y_minus_2q);
__mmask8 sign_bits = _mm512_movepi64_mask(*X);
*X = _mm512_mask_add_epi64(*X, sign_bits, *X, twice_modulus);
Expand Down

0 comments on commit a6bb385

Please sign in to comment.