Skip to content

Commit

Permalink
lib: add hint to generate more pipeline friendly code
Browse files Browse the repository at this point in the history
With statistic data of test data files of silesia
the chance of position beyond highThreshold is very
low (~1.3%@L8 in most cases, all <2.5%), and is in
"lowprob area". Add the branch hint so compiler can
get better pipiline codegen.
With this change it is observed ~1% of mozilla and
xml, and slight (0.3%~0.8%) but consistent uplift on
other files on Arm N1.

Signed-off-by: Jun He <[email protected]>
Change-Id: Id9ba1d5c767e975290b5c1bf0ecce906544f4ade
  • Loading branch information
JunHe77 committed May 22, 2022
1 parent fda537b commit f87f5e2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/decompress/zstd_decompress_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,17 @@ void ZSTD_buildFSETable_body(ZSTD_seqSymbol* dt,
for (i=0; i<n; i++) {
tableDecode[position].baseValue = s;
position = (position + step) & tableMask;
while (position > highThreshold) position = (position + step) & tableMask; /* lowprob area */
while (UNLIKELY(position > highThreshold)) position = (position + step) & tableMask; /* lowprob area */
} }
assert(position == 0); /* position must reach all cells once, otherwise normalizedCounter is incorrect */
}

/* Build Decoding table */
{
U32 u;
#if defined(__aarch64__)
__asm__ volatile(".p2align 4");
#endif
for (u=0; u<tableSize; u++) {
U32 const symbol = tableDecode[u].baseValue;
U32 const nextState = symbolNext[symbol]++;
Expand Down

0 comments on commit f87f5e2

Please sign in to comment.