summaryrefslogtreecommitdiff
path: root/libavutil/arm
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi@remlab.net>2022-09-03 18:05:18 +0300
committerMartin Storsjö <martin@martin.st>2022-09-03 23:54:05 +0300
commit620e6e14878de7392f9b5fd109cc8f5ed90dd835 (patch)
tree852f73735a2eb844c5eaea5e13fffe065acbddbd /libavutil/arm
parent164021423a25f02c6253bb8d73ae9a443a129381 (diff)
downloadffmpeg-620e6e14878de7392f9b5fd109cc8f5ed90dd835.tar.gz
arm: relax byte-swap assembler constraints
There are no particular reasons to force the compiler to use the same register as output and input operand. This forces an extra MOV instruction if the input value needs to be reused after the swap. In most cases, this makes no differences, as the compiler will seleect the same register for both operands either way. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil/arm')
-rw-r--r--libavutil/arm/bswap.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/libavutil/arm/bswap.h b/libavutil/arm/bswap.h
index 611ff0ad5b..c3460e035d 100644
--- a/libavutil/arm/bswap.h
+++ b/libavutil/arm/bswap.h
@@ -39,8 +39,10 @@ static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
#define av_bswap16 av_bswap16
static av_always_inline av_const unsigned av_bswap16(unsigned x)
{
- __asm__("rev16 %0, %0" : "+r"(x));
- return x;
+ unsigned y;
+
+ __asm__("rev16 %0, %1" : "=r"(y) : "r"(x));
+ return y;
}
#endif
@@ -48,17 +50,18 @@ static av_always_inline av_const unsigned av_bswap16(unsigned x)
#define av_bswap32 av_bswap32
static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
{
+ uint32_t y;
#if HAVE_ARMV6_INLINE
- __asm__("rev %0, %0" : "+r"(x));
+ __asm__("rev %0, %1" : "=r"(y) : "r"(x));
#else
uint32_t t;
- __asm__ ("eor %1, %0, %0, ror #16 \n\t"
+ __asm__ ("eor %1, %2, %2, ror #16 \n\t"
"bic %1, %1, #0xFF0000 \n\t"
- "mov %0, %0, ror #8 \n\t"
+ "mov %0, %2, ror #8 \n\t"
"eor %0, %0, %1, lsr #8 \n\t"
- : "+r"(x), "=&r"(t));
+ : "=r"(y), "=&r"(t) : "r"(x));
#endif /* HAVE_ARMV6_INLINE */
- return x;
+ return y;
}
#endif /* AV_GCC_VERSION_AT_MOST(4,4) */