decompress: conditionally remove bmi2 from context
Use an helper function, which will just return 0 in case the feature is disabled. Allows constant propagation and removal of dead code.
This commit is contained in:
@@ -261,7 +261,9 @@ static void ZSTD_initDCtx_internal(ZSTD_DCtx* dctx)
|
|||||||
#endif
|
#endif
|
||||||
dctx->noForwardProgress = 0;
|
dctx->noForwardProgress = 0;
|
||||||
dctx->oversizedDuration = 0;
|
dctx->oversizedDuration = 0;
|
||||||
dctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid());
|
#if DYNAMIC_BMI2
|
||||||
|
dctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid())
|
||||||
|
#endif
|
||||||
dctx->ddictSet = NULL;
|
dctx->ddictSet = NULL;
|
||||||
ZSTD_DCtx_resetParameters(dctx);
|
ZSTD_DCtx_resetParameters(dctx);
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||||
|
|||||||
@@ -133,11 +133,11 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
|
|||||||
if (singleStream) {
|
if (singleStream) {
|
||||||
hufSuccess = HUF_decompress1X_usingDTable_bmi2(
|
hufSuccess = HUF_decompress1X_usingDTable_bmi2(
|
||||||
dctx->litBuffer, litSize, istart+lhSize, litCSize,
|
dctx->litBuffer, litSize, istart+lhSize, litCSize,
|
||||||
dctx->HUFptr, dctx->bmi2);
|
dctx->HUFptr, ZSTD_DCtx_get_bmi2(dctx));
|
||||||
} else {
|
} else {
|
||||||
hufSuccess = HUF_decompress4X_usingDTable_bmi2(
|
hufSuccess = HUF_decompress4X_usingDTable_bmi2(
|
||||||
dctx->litBuffer, litSize, istart+lhSize, litCSize,
|
dctx->litBuffer, litSize, istart+lhSize, litCSize,
|
||||||
dctx->HUFptr, dctx->bmi2);
|
dctx->HUFptr, ZSTD_DCtx_get_bmi2(dctx));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (singleStream) {
|
if (singleStream) {
|
||||||
@@ -150,13 +150,13 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
|
|||||||
hufSuccess = HUF_decompress1X1_DCtx_wksp_bmi2(
|
hufSuccess = HUF_decompress1X1_DCtx_wksp_bmi2(
|
||||||
dctx->entropy.hufTable, dctx->litBuffer, litSize,
|
dctx->entropy.hufTable, dctx->litBuffer, litSize,
|
||||||
istart+lhSize, litCSize, dctx->workspace,
|
istart+lhSize, litCSize, dctx->workspace,
|
||||||
sizeof(dctx->workspace), dctx->bmi2);
|
sizeof(dctx->workspace), ZSTD_DCtx_get_bmi2(dctx));
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
hufSuccess = HUF_decompress4X_hufOnly_wksp_bmi2(
|
hufSuccess = HUF_decompress4X_hufOnly_wksp_bmi2(
|
||||||
dctx->entropy.hufTable, dctx->litBuffer, litSize,
|
dctx->entropy.hufTable, dctx->litBuffer, litSize,
|
||||||
istart+lhSize, litCSize, dctx->workspace,
|
istart+lhSize, litCSize, dctx->workspace,
|
||||||
sizeof(dctx->workspace), dctx->bmi2);
|
sizeof(dctx->workspace), ZSTD_DCtx_get_bmi2(dctx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,7 +620,7 @@ size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
|
|||||||
LL_defaultDTable, dctx->fseEntropy,
|
LL_defaultDTable, dctx->fseEntropy,
|
||||||
dctx->ddictIsCold, nbSeq,
|
dctx->ddictIsCold, nbSeq,
|
||||||
dctx->workspace, sizeof(dctx->workspace),
|
dctx->workspace, sizeof(dctx->workspace),
|
||||||
dctx->bmi2);
|
ZSTD_DCtx_get_bmi2(dctx));
|
||||||
RETURN_ERROR_IF(ZSTD_isError(llhSize), corruption_detected, "ZSTD_buildSeqTable failed");
|
RETURN_ERROR_IF(ZSTD_isError(llhSize), corruption_detected, "ZSTD_buildSeqTable failed");
|
||||||
ip += llhSize;
|
ip += llhSize;
|
||||||
}
|
}
|
||||||
@@ -632,7 +632,7 @@ size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
|
|||||||
OF_defaultDTable, dctx->fseEntropy,
|
OF_defaultDTable, dctx->fseEntropy,
|
||||||
dctx->ddictIsCold, nbSeq,
|
dctx->ddictIsCold, nbSeq,
|
||||||
dctx->workspace, sizeof(dctx->workspace),
|
dctx->workspace, sizeof(dctx->workspace),
|
||||||
dctx->bmi2);
|
ZSTD_DCtx_get_bmi2(dctx));
|
||||||
RETURN_ERROR_IF(ZSTD_isError(ofhSize), corruption_detected, "ZSTD_buildSeqTable failed");
|
RETURN_ERROR_IF(ZSTD_isError(ofhSize), corruption_detected, "ZSTD_buildSeqTable failed");
|
||||||
ip += ofhSize;
|
ip += ofhSize;
|
||||||
}
|
}
|
||||||
@@ -644,7 +644,7 @@ size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
|
|||||||
ML_defaultDTable, dctx->fseEntropy,
|
ML_defaultDTable, dctx->fseEntropy,
|
||||||
dctx->ddictIsCold, nbSeq,
|
dctx->ddictIsCold, nbSeq,
|
||||||
dctx->workspace, sizeof(dctx->workspace),
|
dctx->workspace, sizeof(dctx->workspace),
|
||||||
dctx->bmi2);
|
ZSTD_DCtx_get_bmi2(dctx));
|
||||||
RETURN_ERROR_IF(ZSTD_isError(mlhSize), corruption_detected, "ZSTD_buildSeqTable failed");
|
RETURN_ERROR_IF(ZSTD_isError(mlhSize), corruption_detected, "ZSTD_buildSeqTable failed");
|
||||||
ip += mlhSize;
|
ip += mlhSize;
|
||||||
}
|
}
|
||||||
@@ -1379,7 +1379,7 @@ ZSTD_decompressSequences(ZSTD_DCtx* dctx, void* dst, size_t maxDstSize,
|
|||||||
{
|
{
|
||||||
DEBUGLOG(5, "ZSTD_decompressSequences");
|
DEBUGLOG(5, "ZSTD_decompressSequences");
|
||||||
#if DYNAMIC_BMI2
|
#if DYNAMIC_BMI2
|
||||||
if (dctx->bmi2) {
|
if (ZSTD_DCtx_get_bmi2(dctx)) {
|
||||||
return ZSTD_decompressSequences_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
|
return ZSTD_decompressSequences_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1403,7 +1403,7 @@ ZSTD_decompressSequencesLong(ZSTD_DCtx* dctx,
|
|||||||
{
|
{
|
||||||
DEBUGLOG(5, "ZSTD_decompressSequencesLong");
|
DEBUGLOG(5, "ZSTD_decompressSequencesLong");
|
||||||
#if DYNAMIC_BMI2
|
#if DYNAMIC_BMI2
|
||||||
if (dctx->bmi2) {
|
if (ZSTD_DCtx_get_bmi2(dctx)) {
|
||||||
return ZSTD_decompressSequencesLong_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
|
return ZSTD_decompressSequencesLong_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -136,7 +136,9 @@ struct ZSTD_DCtx_s
|
|||||||
size_t litSize;
|
size_t litSize;
|
||||||
size_t rleSize;
|
size_t rleSize;
|
||||||
size_t staticSize;
|
size_t staticSize;
|
||||||
|
#if DYNAMIC_BMI2 != 0
|
||||||
int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
|
int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* dictionary */
|
/* dictionary */
|
||||||
ZSTD_DDict* ddictLocal;
|
ZSTD_DDict* ddictLocal;
|
||||||
@@ -185,6 +187,14 @@ struct ZSTD_DCtx_s
|
|||||||
#endif
|
#endif
|
||||||
}; /* typedef'd to ZSTD_DCtx within "zstd.h" */
|
}; /* typedef'd to ZSTD_DCtx within "zstd.h" */
|
||||||
|
|
||||||
|
MEM_STATIC int ZSTD_DCtx_get_bmi2(const struct ZSTD_DCtx_s *dctx) {
|
||||||
|
#if DYNAMIC_BMI2 != 0
|
||||||
|
return dctx->bmi2;
|
||||||
|
#else
|
||||||
|
(void)dctx;
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*-*******************************************************
|
/*-*******************************************************
|
||||||
* Shared internal functions
|
* Shared internal functions
|
||||||
|
|||||||
+1
-1
@@ -177,7 +177,7 @@ FORCE_NOINLINE size_t ZSTD_decodeLiteralsHeader(ZSTD_DCtx* dctx, void const* src
|
|||||||
dctx->entropy.hufTable,
|
dctx->entropy.hufTable,
|
||||||
istart+lhSize, litCSize,
|
istart+lhSize, litCSize,
|
||||||
dctx->workspace, sizeof(dctx->workspace),
|
dctx->workspace, sizeof(dctx->workspace),
|
||||||
dctx->bmi2);
|
ZSTD_DCtx_get_bmi2(dctx));
|
||||||
#else
|
#else
|
||||||
return HUF_readDTableX2_wksp(
|
return HUF_readDTableX2_wksp(
|
||||||
dctx->entropy.hufTable,
|
dctx->entropy.hufTable,
|
||||||
|
|||||||
Reference in New Issue
Block a user