* [FFmpeg-devel] [PATCH 2/2] riscv/intmath: use builtins for counting ones
@ 2023-04-20 17:53 Rémi Denis-Courmont
0 siblings, 0 replies; only message in thread
From: Rémi Denis-Courmont @ 2023-04-20 17:53 UTC (permalink / raw)
To: ffmpeg-devel
As with the earlier bswap change, all versions of GCC and Clang that
support RISC-V support the popcount built-ins, so we can just use them
instead of inline assembler.
---
libavutil/riscv/intmath.h | 30 ++++--------------------------
1 file changed, 4 insertions(+), 26 deletions(-)
diff --git a/libavutil/riscv/intmath.h b/libavutil/riscv/intmath.h
index 45bce9a0e7..ae9ee7775b 100644
--- a/libavutil/riscv/intmath.h
+++ b/libavutil/riscv/intmath.h
@@ -69,35 +69,13 @@ static av_always_inline av_const int av_clip_intp2_rvi(int a, int p)
return b;
}
-#if defined (__riscv_zbb) && (__riscv_zbb > 0) && HAVE_INLINE_ASM
-
-#define av_popcount av_popcount_rvb
-static av_always_inline av_const int av_popcount_rvb(uint32_t x)
-{
- int ret;
-
+#if defined (__GNUC__) || defined (__clang__)
+#define av_popcount __builtin_popcount
#if (__riscv_xlen >= 64)
- __asm__ ("cpopw %0, %1\n" : "=r" (ret) : "r" (x));
+#define av_popcount64 __builtin_popcountl
#else
- __asm__ ("cpop %0, %1\n" : "=r" (ret) : "r" (x));
+#define av_popcount64 __builtin_popcountll
#endif
- return ret;
-}
-
-#if (__riscv_xlen >= 64)
-#define av_popcount64 av_popcount64_rvb
-static av_always_inline av_const int av_popcount64_rvb(uint64_t x)
-{
- int ret;
-
-#if (__riscv_xlen >= 128)
- __asm__ ("cpopd %0, %1\n" : "=r" (ret) : "r" (x));
-#else
- __asm__ ("cpop %0, %1\n" : "=r" (ret) : "r" (x));
#endif
- return ret;
-}
-#endif /* __riscv_xlen >= 64 */
-#endif /* __riscv_zbb */
#endif /* AVUTIL_RISCV_INTMATH_H */
--
2.40.0
_______________________________________________
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] only message in thread
only message in thread, other threads:[~2023-04-20 17:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 17:53 [FFmpeg-devel] [PATCH 2/2] riscv/intmath: use builtins for counting ones Rémi Denis-Courmont
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