]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
a47a20365fe01fc114d5c5694bb7fb09c89c6c43
[thirdparty/openembedded/openembedded-core-contrib.git] /
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
6
7 Fixes assembling with binutil as >= 2.41
8
9 Upstream-Status: Backport [https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/effadce6c756247ea8bae32dc13bb3e6f464f0eb]
10 Signed-off-by: James Almer <jamrial@gmail.com>
11 ---
12 libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
13 1 file changed, 23 insertions(+), 3 deletions(-)
14
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
19 @@ -35,12 +35,20 @@
20 static av_always_inline av_const int MULL(int a, int b, unsigned shift)
21 {
22 int rt, dummy;
23 + if (__builtin_constant_p(shift))
24 __asm__ (
25 "imull %3 \n\t"
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)
30 );
31 + else
32 + __asm__ (
33 + "imull %3 \n\t"
34 + "shrdl %4, %%edx, %%eax \n\t"
35 + :"=a"(rt), "=d"(dummy)
36 + :"a"(a), "rm"(b), "c"((uint8_t)shift)
37 + );
38 return rt;
39 }
40
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"
47 : "+r" (a)
48 - : "ic" ((uint8_t)(-s))
49 + : "i" (-s & 0x1F)
50 );
51 + else
52 + __asm__ ("sarl %1, %0\n\t"
53 + : "+r" (a)
54 + : "c" ((uint8_t)(-s))
55 + );
56 return a;
57 }
58
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"
63 : "+r" (a)
64 - : "ic" ((uint8_t)(-s))
65 + : "i" (-s & 0x1F)
66 );
67 + else
68 + __asm__ ("shrl %1, %0\n\t"
69 + : "+r" (a)
70 + : "c" ((uint8_t)(-s))
71 + );
72 return a;
73 }
74
75 --
76 2.41.0
77