simplify ZSTD_preserveUnsortedMark() implementation

since no compiler attempts to auto-vectorize it.
This commit is contained in:
Yann Collet 2017-12-30 11:13:52 +01:00
parent 77fc611abe
commit eb52e2f45e

View File

@ -21,29 +21,16 @@
But candidate 1 cannot hide a large tree of candidates, so it's a moderate loss. But candidate 1 cannot hide a large tree of candidates, so it's a moderate loss.
The benefit is that ZSTD_DUBT_UNSORTED_MARK cannot be misdhandled by a table re-use using a different strategy */ The benefit is that ZSTD_DUBT_UNSORTED_MARK cannot be misdhandled by a table re-use using a different strategy */
#define ZSTD_ROWSIZE 16
/*! ZSTD_preserveUnsortedMark_internal() :
* Helps auto-vectorization */
static void ZSTD_preserveUnsortedMark_internal (U32* const table, int const nbRows, U32 const reducerValue)
{
int cellNb = 0;
int rowNb;
for (rowNb=0 ; rowNb < nbRows ; rowNb++) {
int column;
for (column=0; column<ZSTD_ROWSIZE; column++) {
if (table[cellNb] == ZSTD_DUBT_UNSORTED_MARK)
table[cellNb] = ZSTD_DUBT_UNSORTED_MARK + reducerValue;
} }
}
/*! ZSTD_preserveUnsortedMark() : /*! ZSTD_preserveUnsortedMark() :
* pre-emptively increase value of ZSTD_DUBT_UNSORTED_MARK * pre-emptively increase value of ZSTD_DUBT_UNSORTED_MARK
* to preserve it since table is going to be offset by ZSTD_reduceTable() */ * before ZSTD_reduceTable()
* sp that final operation preserves its value */
void ZSTD_preserveUnsortedMark (U32* const table, U32 const size, U32 const reducerValue) void ZSTD_preserveUnsortedMark (U32* const table, U32 const size, U32 const reducerValue)
{ {
assert((size & (ZSTD_ROWSIZE-1)) == 0); /* multiple of ZSTD_ROWSIZE */ U32 u;
assert(size < (1U<<31)); /* can be casted to int */ for (u=0; u<size; u++)
ZSTD_preserveUnsortedMark_internal(table, size/ZSTD_ROWSIZE, reducerValue); if (table[u] == ZSTD_DUBT_UNSORTED_MARK)
table[u] = ZSTD_DUBT_UNSORTED_MARK + reducerValue;
} }
void ZSTD_updateDUBT(ZSTD_CCtx* zc, void ZSTD_updateDUBT(ZSTD_CCtx* zc,