linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib/ext2fs: Use __builtin_popcount when available Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
@ 2013-01-06 15:04 Cristian Rodríguez
  2013-01-06 22:20 ` Theodore Ts'o
  0 siblings, 1 reply; 6+ messages in thread
From: Cristian Rodríguez @ 2013-01-06 15:04 UTC (permalink / raw)
  To: linux-ext4; +Cc: Cristian Rodríguez

---
 lib/ext2fs/bitops.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c
index 7c3f215..0668469 100644
--- a/lib/ext2fs/bitops.c
+++ b/lib/ext2fs/bitops.c
@@ -125,11 +125,15 @@ static unsigned int popcount8(unsigned int w)
 
 static unsigned int popcount32(unsigned int w)
 {
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+	return __builtin_popcount(w);
+#else
 	unsigned int res = w - ((w >> 1) & 0x55555555);
 	res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
 	res = (res + (res >> 4)) & 0x0F0F0F0F;
 	res = res + (res >> 8);
 	return (res + (res >> 16)) & 0x000000FF;
+#endif
 }
 
 unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes)
-- 
1.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-01-07  1:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-06 15:04 [PATCH] lib/ext2fs: Use __builtin_popcount when available Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org> Cristian Rodríguez
2013-01-06 22:20 ` Theodore Ts'o
2013-01-07  0:53   ` Cristian Rodríguez
2013-01-07  1:31     ` Theodore Ts'o
2013-01-07  1:46       ` Cristian Rodríguez
2013-01-07  1:56         ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).