diff options
author | Jun He <jun.he@arm.com> | 2021-08-03 15:36:20 +0800 |
---|---|---|
committer | Jun He <jun.he@arm.com> | 2021-08-12 15:19:53 +0800 |
commit | d643b9a98888bdc746e8b19621ab19208e79fdac (patch) | |
tree | 91de07ba3b464ef61f3c474211993443ed212884 | |
parent | f2db8f77ce469ce00e33657b981e41a1bd1daf16 (diff) | |
download | snappy-git-d643b9a98888bdc746e8b19621ab19208e79fdac.tar.gz |
decompress: add hint to remove extra AND
Clang doesn't realize the load with free zero-extension,
and emits another extra 'and xn, xm, 0xff' to calc offset.
With this change ,this extra op is removed, and consistent
1.7% performance uplift is observed.
Signed-off-by: Jun He <jun.he@arm.com>
Change-Id: Ica4617852c4b93eadc6c5c551dc3961ffbadb8f0
-rw-r--r-- | snappy.cc | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -1108,6 +1108,15 @@ std::pair<const uint8_t*, ptrdiff_t> DecompressBranchless( // ip points just past the tag and we are touching at maximum kSlopBytes // in an iteration. size_t tag = ip[-1]; +#if defined(__clang__) && defined(__aarch64__) + // Workaround for https://bugs.llvm.org/show_bug.cgi?id=51317 + // when loading 1 byte, clang for aarch64 doesn't realize that it(ldrb) + // comes with free zero-extension, so clang generates another + // 'and xn, xm, 0xff' before it use that as the offset. This 'and' is + // redundant and can be removed by adding this dummy asm, which gives + // clang a hint that we're doing the zero-extension at the load. + asm("" ::"r"(tag)); +#endif do { // The throughput is limited by instructions, unrolling the inner loop // twice reduces the amount of instructions checking limits and also |