Skip to content

Commit 6e58e9a

Browse files
authored
Merge pull request #4509 from arpadpanyik-arm/revert_branch_opt
AArch64: Revert previous branch optimization
2 parents 23dae4b + 0dffae4 commit 6e58e9a

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

lib/decompress/zstd_decompress_block.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,7 @@ ZSTD_decodeSequence(seqState_t* seqState, const ZSTD_longOffset_e longOffsets, c
12611261
const ZSTD_seqSymbol* const mlDInfo = seqState->stateML.table + seqState->stateML.state;
12621262
const ZSTD_seqSymbol* const ofDInfo = seqState->stateOffb.table + seqState->stateOffb.state;
12631263
# endif
1264+
(void)longOffsets;
12641265
seq.matchLength = mlDInfo->baseValue;
12651266
seq.litLength = llDInfo->baseValue;
12661267
{ U32 const ofBase = ofDInfo->baseValue;
@@ -1290,18 +1291,7 @@ ZSTD_decodeSequence(seqState_t* seqState, const ZSTD_longOffset_e longOffsets, c
12901291
ZSTD_STATIC_ASSERT(LONG_OFFSETS_MAX_EXTRA_BITS_32 == 5);
12911292
ZSTD_STATIC_ASSERT(STREAM_ACCUMULATOR_MIN_32 > LONG_OFFSETS_MAX_EXTRA_BITS_32);
12921293
ZSTD_STATIC_ASSERT(STREAM_ACCUMULATOR_MIN_32 - LONG_OFFSETS_MAX_EXTRA_BITS_32 >= MaxMLBits);
1293-
if (MEM_32bits() && longOffsets && (ofBits >= STREAM_ACCUMULATOR_MIN_32)) {
1294-
/* Always read extra bits, this keeps the logic simple,
1295-
* avoids branches, and avoids accidentally reading 0 bits.
1296-
*/
1297-
U32 const extraBits = LONG_OFFSETS_MAX_EXTRA_BITS_32;
1298-
offset = ofBase + (BIT_readBitsFast(&seqState->DStream, ofBits - extraBits) << extraBits);
1299-
BIT_reloadDStream(&seqState->DStream);
1300-
offset += BIT_readBitsFast(&seqState->DStream, extraBits);
1301-
} else {
1302-
offset = ofBase + BIT_readBitsFast(&seqState->DStream, ofBits/*>0*/); /* <= (ZSTD_WINDOWLOG_MAX-1) bits */
1303-
if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream);
1304-
}
1294+
offset = ofBase + BIT_readBitsFast(&seqState->DStream, ofBits/*>0*/); /* <= (ZSTD_WINDOWLOG_MAX-1) bits */
13051295
prevOffset2 = prevOffset1;
13061296
prevOffset1 = prevOffset0;
13071297
prevOffset0 = offset;
@@ -1332,32 +1322,25 @@ ZSTD_decodeSequence(seqState_t* seqState, const ZSTD_longOffset_e longOffsets, c
13321322
seq.offset = offset;
13331323
}
13341324

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

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-
}
1328+
if (UNLIKELY(totalBits >= STREAM_ACCUMULATOR_MIN_64-(LLFSELog+MLFSELog+OffFSELog)))
1329+
BIT_reloadDStream(&seqState->DStream);
13431330

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

13471334
if (llBits > 0)
13481335
seq.litLength += BIT_readBitsFast(&seqState->DStream, llBits/*>0*/);
13491336

1350-
if (MEM_32bits())
1351-
BIT_reloadDStream(&seqState->DStream);
1352-
13531337
DEBUGLOG(6, "seq: litL=%u, matchL=%u, offset=%u",
13541338
(U32)seq.litLength, (U32)seq.matchLength, (U32)seq.offset);
13551339

13561340
if (!isLastSeq) {
13571341
/* Don't update FSE state for last sequence. */
13581342
ZSTD_updateFseStateWithDInfo(&seqState->stateLL, &seqState->DStream, llNext, llnbBits); /* <= 9 bits */
13591343
ZSTD_updateFseStateWithDInfo(&seqState->stateML, &seqState->DStream, mlNext, mlnbBits); /* <= 9 bits */
1360-
if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream); /* <= 18 bits */
13611344
ZSTD_updateFseStateWithDInfo(&seqState->stateOffb, &seqState->DStream, ofNext, ofnbBits); /* <= 8 bits */
13621345
BIT_reloadDStream(&seqState->DStream);
13631346
}

0 commit comments

Comments
 (0)