Commit c308e9f2 for xz
commit c308e9f27201300fd042d3e7324a21e55c25852f
Author: Lasse Collin <lasse.collin@tukaani.org>
Date: Mon Nov 23 12:27:47 2026 +0200
liblzma: Tweak rc_direct() x86-64 assembly
This seems slightly faster on modern processors when microbenchmarking.
It also needs one fewer temporary variable.
rc_direct() is the least hottest thing that has inline assembly, so in
practice this change shouldn't make a noticeable difference in speed.
diff --git a/src/liblzma/rangecoder/range_decoder.h b/src/liblzma/rangecoder/range_decoder.h
index bcc53dbe..224ecf68 100644
--- a/src/liblzma/rangecoder/range_decoder.h
+++ b/src/liblzma/rangecoder/range_decoder.h
@@ -930,27 +930,24 @@ do { \
#define rc_direct(dest_var, count_var) \
do { \
uint32_t t0; \
- uint32_t t1; \
\
__asm__( \
"2:\n\t" \
"add %[dest], %[dest]\n\t" \
- "lea 1(%q[dest]), %[t1]\n\t" \
\
rc_asm_normalize \
\
"shr $1, %[range]\n\t" \
"mov %[code], %[t0]\n\t" \
"sub %[range], %[code]\n\t" \
- "cmovns %[t1], %[dest]\n\t" \
"cmovs %[t0], %[code]\n\t" \
+ "sbb $-1, %[dest]\n\t" \
"dec %[count]\n\t" \
"jnz 2b\n\t" \
: \
[range] "+&r"(rc.range), \
[code] "+&r"(rc.code), \
[t0] "=&r"(t0), \
- [t1] "=&r"(t1), \
[dest] "+&r"(dest_var), \
[count] "+&r"(count_var), \
[in_ptr] "+&r"(rc_in_ptr) \