Commit 6cce4d0c9c for ffmpeg
commit 6cce4d0c9cb36b597a7e310d7b0371ae9ea7ef1b
Author: Ramiro Polla <ramiro.polla@gmail.com>
Date: Mon Nov 2 00:03:13 2026 +0100
avcodec/x86/cabac: don't make the tables address computation volatile
The lea that loads the address of ff_h264_cabac_tables has no side
effects, so the compiler is free to move it out of loops or merge
multiple instances of it.
Speedup of single-threaded H.264 decoding on an i9-13900K:
P-core E-core
1080p 3M +0.4% +0.1%
1080p 15M +0.1% +0.1%
1080p 30M +0.2% +0.2%
4K 150M +0.1% +0.2%
Geometric Mean +0.2% +0.2%
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 3ddd876f5c..8d54d2ad40 100644
--- a/libavcodec/x86/cabac.h
+++ b/libavcodec/x86/cabac.h
@@ -215,7 +215,7 @@ int get_cabac_inline_x86(CABACContext *c, uint8_t *const state)
#ifdef BROKEN_RELOCATIONS
void *tables;
- __asm__ volatile(
+ __asm__(
"lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
: "=&r"(tables)
: NAMED_CONSTRAINTS_ARRAY(ff_h264_cabac_tables)
diff --git a/libavcodec/x86/h264_cabac.c b/libavcodec/x86/h264_cabac.c
index 51d098cd7a..d0a4541083 100644
--- a/libavcodec/x86/h264_cabac.c
+++ b/libavcodec/x86/h264_cabac.c
@@ -56,7 +56,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff,
#ifdef BROKEN_RELOCATIONS
void *tables;
- __asm__ volatile(
+ __asm__(
"lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
: "=&r"(tables)
: NAMED_CONSTRAINTS_ARRAY(ff_h264_cabac_tables)
@@ -136,7 +136,7 @@ static int decode_significance_8x8_x86(CABACContext *c,
#ifdef BROKEN_RELOCATIONS
void *tables;
- __asm__ volatile(
+ __asm__(
"lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
: "=&r"(tables)
: NAMED_CONSTRAINTS_ARRAY(ff_h264_cabac_tables)