Commit a239b68d48 for ffmpeg
commit a239b68d48602173459a90d5d7699ed3d76cfd5a
Author: Ramiro Polla <ramiro.polla@gmail.com>
Date: Mon Nov 2 01:14:12 2026 +0100
avcodec/x86/cabac: remove the cmov-free x86-64 PIC version of get_cabac
HAVE_FAST_CMOV is only disabled on x86-64 when configuring with
--cpu=pentium4, pentium4m, prescott or nocona (or --cpu=host on these
CPUs), on which cmov is supported but slow. Generic x86-64 builds, as
shipped by distributions, already use the cmov version on these CPUs.
Avoiding cmov here is also inconsistent with the rest of these builds,
since gcc freely emits cmov with -march=nocona.
The upcoming cabac optimizations use cmov in the x86-64 version of
BRANCHLESS_GET_CABAC, and keeping a cmov-free version of each of them
for these builds is not worth it, so drop the cmov-free variant.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h
index ce5b831754..206b4e4346 100644
--- a/libavcodec/x86/cabac.h
+++ b/libavcodec/x86/cabac.h
@@ -52,29 +52,6 @@
#ifdef BROKEN_RELOCATIONS
#define TABLES_ARG , "r"(tables)
-#if HAVE_FAST_CMOV
-#define BRANCHLESS_GET_CABAC_UPDATE(ret, retq, low, range, tmp) \
- "cmp "low" , "tmp" \n\t"\
- "cmova %%ecx , "range" \n\t"\
- "sbb %%rcx , %%rcx \n\t"\
- "and %%ecx , "tmp" \n\t"\
- "xor %%rcx , "retq" \n\t"\
- "sub "tmp" , "low" \n\t"
-#else /* HAVE_FAST_CMOV */
-#define BRANCHLESS_GET_CABAC_UPDATE(ret, retq, low, range, tmp) \
-/* P4 Prescott has crappy cmov,sbb,64-bit shift so avoid them */ \
- "sub "low" , "tmp" \n\t"\
- "sar $31 , "tmp" \n\t"\
- "sub %%ecx , "range" \n\t"\
- "and "tmp" , "range" \n\t"\
- "add %%ecx , "range" \n\t"\
- "shl $17 , %%ecx \n\t"\
- "and "tmp" , %%ecx \n\t"\
- "sub %%ecx , "low" \n\t"\
- "xor "tmp" , "ret" \n\t"\
- "movslq "ret" , "retq" \n\t"
-#endif /* HAVE_FAST_CMOV */
-
#ifdef __LZCNT__
/* renormalisation shift = lzcnt(range) - 23, refill shift = tzcnt(low) - 16 */
#define BRANCHLESS_GET_CABAC_RENORM(range, rangeq, norm_off, tables) \
@@ -116,7 +93,12 @@
"sub "range" , "tmp" \n\t"\
"mov "tmp" , %%ecx \n\t"\
"shl $17 , "tmp" \n\t"\
- BRANCHLESS_GET_CABAC_UPDATE(ret, retq, low, range, tmp) \
+ "cmp "low" , "tmp" \n\t"\
+ "cmova %%ecx , "range" \n\t"\
+ "sbb %%rcx , %%rcx \n\t"\
+ "and %%ecx , "tmp" \n\t"\
+ "xor %%rcx , "retq" \n\t"\
+ "sub "tmp" , "low" \n\t"\
BRANCHLESS_GET_CABAC_RENORM(range, rangeq, norm_off, tables) \
"shl %%cl , "range" \n\t"\
"movzbl "mlps_off"+128("tables", "retq"), "tmp" \n\t"\