Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Dec 2003 17:19:40 -0800 (PST)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 43332 for review
Message-ID:  <200312030119.hB31JexD091510@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=43332

Change 43332 by peter@peter_overcee on 2003/12/02 17:19:39

	replace the handrolled ffs() with __builtin_ffs(), which gcc
	does a better job of with instruction sets >= pentiumpro.
	For example, it uses the conditional move instructions to avoid
	branches.

Affected files ...

.. //depot/projects/hammer/sys/amd64/include/cpufunc.h#13 edit

Differences ...

==== //depot/projects/hammer/sys/amd64/include/cpufunc.h#13 (text+ko) ====

@@ -129,13 +129,18 @@
 static __inline int
 ffs(int mask)
 {
+#if 0
 	/*
 	 * Note that gcc-2's builtin ffs would be used if we didn't declare
 	 * this inline or turn off the builtin.  The builtin is faster but
 	 * broken in gcc-2.4.5 and slower but working in gcc-2.5 and later
 	 * versions.
 	 */
-	 return (mask == 0 ? mask : (int)bsfl((u_int)mask) + 1);
+	return (mask == 0 ? mask : (int)bsfl((u_int)mask) + 1);
+#else
+	/* Actually, the above is way out of date.  The builtins use cmov etc */
+	return (__builtin_ffs(mask));
+#endif
 }
 
 #define	HAVE_INLINE_FLS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312030119.hB31JexD091510>