1 From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
3 Date: Sun, 16 Jul 2023 18:18:02 +0300
4 Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
5 instructions within inline assembly
7 Fixes assembling with binutil as >= 2.41
9 Upstream-Status: Backport [https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/effadce6c756247ea8bae32dc13bb3e6f464f0eb]
10 Signed-off-by: James Almer <jamrial@gmail.com>
12 libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
13 1 file changed, 23 insertions(+), 3 deletions(-)
15 diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
16 index 6298f5ed19..ca7e2dffc1 100644
17 --- a/libavcodec/x86/mathops.h
18 +++ b/libavcodec/x86/mathops.h
20 static av_always_inline av_const int MULL(int a, int b, unsigned shift)
23 + if (__builtin_constant_p(shift))
26 "shrdl %4, %%edx, %%eax \n\t"
27 :"=a"(rt), "=d"(dummy)
28 - :"a"(a), "rm"(b), "ci"((uint8_t)shift)
29 + :"a"(a), "rm"(b), "i"(shift & 0x1F)
34 + "shrdl %4, %%edx, %%eax \n\t"
35 + :"=a"(rt), "=d"(dummy)
36 + :"a"(a), "rm"(b), "c"((uint8_t)shift)
41 @@ -113,19 +121,31 @@ __asm__ volatile(\
42 // avoid +32 for shift optimization (gcc should do that ...)
43 #define NEG_SSR32 NEG_SSR32
44 static inline int32_t NEG_SSR32( int32_t a, int8_t s){
45 + if (__builtin_constant_p(s))
46 __asm__ ("sarl %1, %0\n\t"
48 - : "ic" ((uint8_t)(-s))
52 + __asm__ ("sarl %1, %0\n\t"
54 + : "c" ((uint8_t)(-s))
59 #define NEG_USR32 NEG_USR32
60 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
61 + if (__builtin_constant_p(s))
62 __asm__ ("shrl %1, %0\n\t"
64 - : "ic" ((uint8_t)(-s))
68 + __asm__ ("shrl %1, %0\n\t"
70 + : "c" ((uint8_t)(-s))