From 455fa8c4176389e463a1c052638d2a3f85e70d95 Mon Sep 17 00:00:00 2001 From: Lam Pham-Sy Date: Tue, 7 Aug 2018 12:19:32 +0200 Subject: [PATCH] Address comments --- src/fec_rs_nf4.h | 2 +- src/simd_nf4.h | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/fec_rs_nf4.h b/src/fec_rs_nf4.h index 0c827a55..fcba4ce6 100644 --- a/src/fec_rs_nf4.h +++ b/src/fec_rs_nf4.h @@ -312,7 +312,7 @@ class RsNf4 : public FecCode { std::vector packed_symbs; // pack marked symbols for (auto const& data : props[frag_id].get_map()) { - off_t loc_offset = data.first.get_offset(); + const off_t loc_offset = data.first.get_offset(); if (loc_offset >= offset && loc_offset < offset_max) { // As loc.offset := offset + j * this->word_size const size_t j = (loc_offset - offset) / this->word_size; diff --git a/src/simd_nf4.h b/src/simd_nf4.h index 61973364..d0052fee 100644 --- a/src/simd_nf4.h +++ b/src/simd_nf4.h @@ -74,7 +74,6 @@ inline aint128 expand32(uint32_t* arr, int n) inline GroupedValues<__uint128_t> unpack(__uint128_t a, int n) { - uint32_t flag; uint16_t ai[8]; aint128 values; @@ -88,10 +87,8 @@ inline GroupedValues<__uint128_t> unpack(__uint128_t a, int n) ai[6] = _mm_extract_epi16(_a, 6); ai[7] = _mm_extract_epi16(_a, 7); - flag = ai[1]; - flag += (ai[3] > 0) ? 2 : 0; - flag += (ai[5] > 0) ? 4 : 0; - flag += (ai[7] > 0) ? 8 : 0; + const uint32_t flag = + ai[1] | (!!ai[3] << 1u) | (!!ai[5] << 2u) | (!!ai[7] << 3u); m128i val = _mm_set_epi64( _mm_setzero_si64(), _mm_set_pi16(ai[6], ai[4], ai[2], ai[0])); @@ -104,7 +101,6 @@ inline GroupedValues<__uint128_t> unpack(__uint128_t a, int n) inline void unpack(__uint128_t a, GroupedValues<__uint128_t>& b, int n) { - uint32_t flag; uint16_t ai[8]; aint128 values; @@ -118,10 +114,8 @@ inline void unpack(__uint128_t a, GroupedValues<__uint128_t>& b, int n) ai[6] = _mm_extract_epi16(_a, 6); ai[7] = _mm_extract_epi16(_a, 7); - flag = ai[1]; - flag += (ai[3] > 0) ? 2 : 0; - flag += (ai[5] > 0) ? 4 : 0; - flag += (ai[7] > 0) ? 8 : 0; + const uint32_t flag = + ai[1] | (!!ai[3] << 1u) | (!!ai[5] << 2u) | (!!ai[7] << 3u); m128i val = _mm_set_epi64( _mm_setzero_si64(), _mm_set_pi16(ai[6], ai[4], ai[2], ai[0]));