1
0
Fork 0

aarch64: 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>
This commit is contained in:
Rémi Denis-Courmont 2022-09-03 18:05:17 +03:00 committed by Martin Storsjö
parent 0b95a6a1d0
commit 164021423a
1 changed files with 12 additions and 6 deletions

View File

@ -28,22 +28,28 @@
#define av_bswap16 av_bswap16
static av_always_inline av_const unsigned av_bswap16(unsigned x)
{
__asm__("rev16 %w0, %w0" : "+r"(x));
return x;
unsigned y;
__asm__("rev16 %w0, %w1" : "=r"(y) : "r"(x));
return y;
}
#define av_bswap32 av_bswap32
static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
{
__asm__("rev %w0, %w0" : "+r"(x));
return x;
uint32_t y;
__asm__("rev %w0, %w1" : "=r"(y) : "r"(x));
return y;
}
#define av_bswap64 av_bswap64
static av_always_inline av_const uint64_t av_bswap64(uint64_t x)
{
__asm__("rev %0, %0" : "+r"(x));
return x;
uint64_t y;
__asm__("rev %0, %1" : "=r"(y) : "r"(x));
return y;
}
#endif /* HAVE_INLINE_ASM */