From c4e64133d881ca446a95ec5c2cfb6a4d138507eb Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Thu, 16 Jul 2020 11:28:24 +0000 Subject: [PATCH] amd64: patch ffsl to use the compiler builtin This shortens fdalloc by over 60 bytes. Correctness verified by running both variants at the same time and comparing the result of each call. Note someone(tm) should make a pass at converting everything else feasible. --- sys/amd64/include/cpufunc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 61959f12a95..94e9c15b511 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -167,7 +167,8 @@ enable_intr(void) static __inline __pure2 int ffsl(long mask) { - return (mask == 0 ? mask : (int)bsfq((u_long)mask) + 1); + + return (__builtin_ffsl(mask)); } #define HAVE_INLINE_FFSLL