The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=aae89f6f09576351cc3a9a54959649e60fdd849b
commit aae89f6f09576351cc3a9a54959649e60fdd849b Author: Mateusz Guzik <m...@freebsd.org> AuthorDate: 2021-01-31 23:35:30 +0000 Commit: Mateusz Guzik <m...@freebsd.org> CommitDate: 2021-02-01 04:53:23 +0000 amd64: use compiler intrinsics for bsf* and bsr* --- sys/amd64/include/cpufunc.h | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 763ed2c64c8a..8ef298e1d7d5 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -65,41 +65,13 @@ breakpoint(void) __asm __volatile("int $3"); } -static __inline __pure2 u_int -bsfl(u_int mask) -{ - u_int result; - - __asm __volatile("bsfl %1,%0" : "=r" (result) : "rm" (mask)); - return (result); -} - -static __inline __pure2 u_long -bsfq(u_long mask) -{ - u_long result; - - __asm __volatile("bsfq %1,%0" : "=r" (result) : "rm" (mask)); - return (result); -} - -static __inline __pure2 u_int -bsrl(u_int mask) -{ - u_int result; +#define bsfl(mask) __builtin_ctz(mask) - __asm __volatile("bsrl %1,%0" : "=r" (result) : "rm" (mask)); - return (result); -} +#define bsfq(mask) __builtin_ctzl(mask) -static __inline __pure2 u_long -bsrq(u_long mask) -{ - u_long result; +#define bsrl(mask) (__builtin_clz(mask) ^ 0x1f) - __asm __volatile("bsrq %1,%0" : "=r" (result) : "rm" (mask)); - return (result); -} +#define bsrq(mask) (__builtin_clzl(mask) ^ 0x3f) static __inline void clflush(u_long addr) _______________________________________________ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"