From e2aeb25e01fa5e59412653265ea7eed318ed7bfc Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Wed, 21 Aug 2024 14:03:43 +0100 Subject: [PATCH] Updated doc comments --- src/hash/rescue/arch/x86_64_avx2.rs | 38 ++++++++++++++++++----------- src/hash/rescue/rpo/tests.rs | 6 ++--- src/merkle/mmr/peaks.rs | 12 ++++----- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/hash/rescue/arch/x86_64_avx2.rs b/src/hash/rescue/arch/x86_64_avx2.rs index fc8c7c1..6626f09 100644 --- a/src/hash/rescue/arch/x86_64_avx2.rs +++ b/src/hash/rescue/arch/x86_64_avx2.rs @@ -5,28 +5,38 @@ use core::arch::x86_64::*; // Preliminary notes: // 1. AVX does not support addition with carry but 128-bit (2-word) addition can be easily emulated. -// The method recognizes that for a + b overflowed iff (a + b) < a: i. res_lo = a_lo + b_lo ii. -// carry_mask = res_lo < a_lo iii. res_hi = a_hi + b_hi - carry_mask Notice that carry_mask is -// subtracted, not added. This is because AVX comparison instructions return -1 (all bits 1) for -// true and 0 for false. +// The method recognizes that for a + b overflowed iff (a + b) < a: +// - i. res_lo = a_lo + b_lo +// - ii. carry_mask = res_lo < a_lo +// - iii. res_hi = a_hi + b_hi - carry_mask Notice that carry_mask is subtracted, not added. +// This is because AVX comparison instructions return -1 (all bits 1) for true and 0 for false. // // 2. AVX does not have unsigned 64-bit comparisons. Those can be emulated with signed comparisons // by recognizing that a