Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

74 lines
2.1KB

  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. Fixes assembling with binutil as >= 2.41
  7. Signed-off-by: James Almer <jamrial@gmail.com>
  8. ---
  9. libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
  10. 1 file changed, 23 insertions(+), 3 deletions(-)
  11. diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
  12. index 6298f5ed1983b..ca7e2dffc1076 100644
  13. --- a/libavcodec/x86/mathops.h
  14. +++ b/libavcodec/x86/mathops.h
  15. @@ -35,12 +35,20 @@
  16. static av_always_inline av_const int MULL(int a, int b, unsigned shift)
  17. {
  18. int rt, dummy;
  19. + if (__builtin_constant_p(shift))
  20. __asm__ (
  21. "imull %3 \n\t"
  22. "shrdl %4, %%edx, %%eax \n\t"
  23. :"=a"(rt), "=d"(dummy)
  24. - :"a"(a), "rm"(b), "ci"((uint8_t)shift)
  25. + :"a"(a), "rm"(b), "i"(shift & 0x1F)
  26. );
  27. + else
  28. + __asm__ (
  29. + "imull %3 \n\t"
  30. + "shrdl %4, %%edx, %%eax \n\t"
  31. + :"=a"(rt), "=d"(dummy)
  32. + :"a"(a), "rm"(b), "c"((uint8_t)shift)
  33. + );
  34. return rt;
  35. }
  36. @@ -113,19 +121,31 @@ __asm__ volatile(\
  37. // avoid +32 for shift optimization (gcc should do that ...)
  38. #define NEG_SSR32 NEG_SSR32
  39. static inline int32_t NEG_SSR32( int32_t a, int8_t s){
  40. + if (__builtin_constant_p(s))
  41. __asm__ ("sarl %1, %0\n\t"
  42. : "+r" (a)
  43. - : "ic" ((uint8_t)(-s))
  44. + : "i" (-s & 0x1F)
  45. );
  46. + else
  47. + __asm__ ("sarl %1, %0\n\t"
  48. + : "+r" (a)
  49. + : "c" ((uint8_t)(-s))
  50. + );
  51. return a;
  52. }
  53. #define NEG_USR32 NEG_USR32
  54. static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
  55. + if (__builtin_constant_p(s))
  56. __asm__ ("shrl %1, %0\n\t"
  57. : "+r" (a)
  58. - : "ic" ((uint8_t)(-s))
  59. + : "i" (-s & 0x1F)
  60. );
  61. + else
  62. + __asm__ ("shrl %1, %0\n\t"
  63. + : "+r" (a)
  64. + : "c" ((uint8_t)(-s))
  65. + );
  66. return a;
  67. }