Skip to content

Commit 33618c8

Browse files
AArch64: Revert previous branch optimization
Revert a branch optimization that was based on an incorrect assumption in the AArch64 part of ZSTD_decodeSequence. In extreme cases the existing implementation could lead to data corruption. Insert an UNLIKELY hint to guide the compilers toward generating more efficient machine code.
1 parent 23dae4b commit 33618c8

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/decompress/zstd_decompress_block.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,14 +1332,11 @@ ZSTD_decodeSequence(seqState_t* seqState, const ZSTD_longOffset_e longOffsets, c
13321332
seq.offset = offset;
13331333
}
13341334

1335-
if (mlBits > 0) {
1335+
if (mlBits > 0)
13361336
seq.matchLength += BIT_readBitsFast(&seqState->DStream, mlBits/*>0*/);
13371337

1338-
if (MEM_32bits() && (mlBits+llBits >= STREAM_ACCUMULATOR_MIN_32-LONG_OFFSETS_MAX_EXTRA_BITS_32))
1339-
BIT_reloadDStream(&seqState->DStream);
1340-
if (MEM_64bits() && (totalBits >= STREAM_ACCUMULATOR_MIN_64-(LLFSELog+MLFSELog+OffFSELog)))
1341-
BIT_reloadDStream(&seqState->DStream);
1342-
}
1338+
if (UNLIKELY(totalBits >= STREAM_ACCUMULATOR_MIN_64-(LLFSELog+MLFSELog+OffFSELog)))
1339+
BIT_reloadDStream(&seqState->DStream);
13431340

13441341
/* Ensure there are enough bits to read the rest of data in 64-bit mode. */
13451342
ZSTD_STATIC_ASSERT(16+LLFSELog+MLFSELog+OffFSELog < STREAM_ACCUMULATOR_MIN_64);

0 commit comments

Comments
 (0)