Tweaked mid to use sign-bit to indicate mroots

This is an intermediate commit as a part of a tangent into compressed
mids.

The idea here, is instead of using bid=-1 as a special value for mroots,
use only the top bit to indicate mroots. This allows you to compare
against the grm/other uninlined mids by masking instead of signed
comparison.

This is valuable for compressed mids since extracting bids relies on
knowledge of the block size, and becomes quite a bit more expensive.

            mroot bid                             mroot cmp
  before:  0xffffffff  lfs_smax32(a, 0) == lfs_smax32(b, 0)
  after:   0x80000000  (a & 0x7fffffff) == (b & 0x7fffffff)

The implementation here is a bit clumsy. I think GCC may be not that
great at optimizing out copies of structs being passed around via
inlined functions. But this is only a proof-of-concept.
This commit is contained in:
Christopher Haster
2023-08-24 15:27:05 -05:00
parent ff87aa41f2
commit 9f18b1fd50
4 changed files with 169 additions and 163 deletions
+1 -1
View File
@@ -412,7 +412,7 @@ typedef struct lfsr_openedmdir {
#define LFSR_GRM_DSIZE (1+5+5+5+5)
typedef struct lfsr_grm {
lfsr_mid_t mids[2];
lfsr_mid_t rms[2];
} lfsr_grm_t;