]> git.ipfire.org Git - thirdparty/zstd.git/commit
Inline BIT_reloadDStream
authorHan Zhu <zhuhan7737@gmail.com>
Mon, 27 Mar 2023 22:57:55 +0000 (15:57 -0700)
committerHan Zhu <zhuhan7737@gmail.com>
Tue, 28 Mar 2023 22:36:02 +0000 (15:36 -0700)
commite6dccbf48246f4e2844251972fcc0946a5de5154
treeb28101555b2ba1ec307e41189757188c90ac432f
parent57e1b45920d0df787bf87671554778e04544846b
Inline BIT_reloadDStream

Inlining `BIT_reloadDStream` provided >3% decompression speed improvement for
clang PGO-optimized zstd binary, measured using the Silesia corpus with
compression level 1. The win comes from improved register allocation which leads
to fewer spills and reloads. Take a look at this comparison of
profile-annotated hot assembly before and after this change:
https://www.diffchecker.com/UjDGIyLz/. The diff is a bit messy, but notice three
fewer moves after inlining.

In general LLVM's register allocator works better when it can see more code. For
example, when the register allocator sees a call instruction, it partitions the
registers into caller registers and callee registers, and it is not free to do
whatever it wants with all the registers for the current function. Inlining the
callee lets the register allocation access all registers and use them more
flexsibly.
lib/common/bitstream.h