* [FFmpeg-devel] [PATCH 2/2] arm: relax byte-swap assembler constraints
@ 2022-09-03 15:05 remi
2022-09-03 20:19 ` Martin Storsjö
0 siblings, 1 reply; 2+ messages in thread
From: remi @ 2022-09-03 15:05 UTC (permalink / raw)
To: ffmpeg-devel
From: Rémi Denis-Courmont <remi@remlab.net>
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.
---
libavutil/arm/bswap.h | 17 ++++++++++-------
1 file 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) */
--
2.37.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] arm: relax byte-swap assembler constraints
2022-09-03 15:05 [FFmpeg-devel] [PATCH 2/2] arm: relax byte-swap assembler constraints remi
@ 2022-09-03 20:19 ` Martin Storsjö
0 siblings, 0 replies; 2+ messages in thread
From: Martin Storsjö @ 2022-09-03 20:19 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, 3 Sep 2022, remi@remlab.net wrote:
> From: Rémi Denis-Courmont <remi@remlab.net>
>
> 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.
> ---
> libavutil/arm/bswap.h | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
These two patches LGTM - I can push them later after running them through
some test builds (even though I don't expect there to be any issues).
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-03 20:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-03 15:05 [FFmpeg-devel] [PATCH 2/2] arm: relax byte-swap assembler constraints remi
2022-09-03 20:19 ` Martin Storsjö
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git