Hi Atsushi,
> If size <= 8, fls((size - 1) >> ALLOC_MINBITS) is fls(0).
> The result of fls(0) is undefined.
Yep, got caught out by this because my previous fls() supported zero.
> I think we have to never call fls(0) from AllocSetFreeIndex().
> My proposal code:
>
> if (size > (1 << ALLOC_MINBITS))
> {
> idx = fls((size - 1) >> ALLOC_MINBITS);
> Assert(idx < ALLOCSET_NUM_FREELISTS);
> }
Looks good, I'll send an updated patch.
Also, are you still seeing the same improvement with the __builtin_clz
as your inline asm implementation?
Cheers,
Jeremy