[patch] use __builtin_ctzl in ggc-page
Steven Bosscher
stevenb@suse.de
Fri Jan 14 18:32:00 GMT 2005
Hi,
The page allocator looks for free objects by keeping bitmaps of
taken slots in a bag. We look for a 0 bit with a loop right now,
but we could use a builtin instead, like Nathan did recently for
the revamped bitmap.c.
Bootstrapped on x86_64-suse-linux-gnu, OK?
Gr.
Steven
* ggc-page.c (ggc_alloc_stat): Use __builtin_ctzl instead of a
loop to look for a free slot in a page entry.
Index: ggc-page.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-page.c,v
retrieving revision 1.96
diff -c -3 -p -r1.96 ggc-page.c
*** ggc-page.c 22 Oct 2004 17:05:05 -0000 1.96
--- ggc-page.c 14 Jan 2005 18:11:43 -0000
*************** ggc_alloc_stat (size_t size MEM_STAT_DEC
*** 1139,1146 ****
--- 1139,1152 ----
word = bit = 0;
while (~entry->in_use_p[word] == 0)
++word;
+
+ #if GCC_VERSION >= 3004
+ bit = __builtin_ctzl (~entry->in_use_p[word]);
+ #else
while ((entry->in_use_p[word] >> bit) & 1)
++bit;
+ #endif
+
hint = word * HOST_BITS_PER_LONG + bit;
}
More information about the Gcc-patches
mailing list