[PATCH v2] string: Use builtins for ffs and ffsll

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Aug 28 13:52:04 GMT 2023



On 28/08/23 10:12, Adhemerval Zanella Netto wrote:
> 
> 
> On 26/08/23 19:18, Wilco Dijkstra wrote:
>> Hi Richard,
>>
>>> With gcc version 12.3.0 (Ubuntu 12.3.0-1ubuntu1~22.04) arm-linux-gnueabihf-gcc,
>>>
>>> int f(long int x) { return __builtin_ffsl(x); }
>>> int g(long long int x) { return __builtin_ffsll(x); }
>>>
>>> The compiler only inlines f.
>>>
>>> That said, it is reasonable to call this a missed optimization and fix the compiler.
>>
>> It was already fixed on trunk. It seems __builtin_ctzll had the same issue.
>>
>> In any case we don't need to waste time trying to optimize the GLIBC ffs/ffsll
>> since they are never called.
> 
> I would say we are discussing two different things here.  My patch intention
> is to remove the multiple ffs/ffsll arch-specific and use compiler to generate
> the optimized instruction were possible.  The idea is not to leverage libgcc,
> since I have not touched string/ffs{ll}.c.
> 
> A possible further cleanup would to indeed remove string/ffs.c, and always use
> the compiler builtin (and thus libgcc).  But I think this should be a different
> patch.

In fact, in the glibc weekly discussion Carlos brought that we should also remove 
the ffs/ffsll benchtests (since there is no much point in having a benchmark for
theses symbols).


More information about the Libc-alpha mailing list