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

Wilco Dijkstra Wilco.Dijkstra@arm.com
Wed Aug 30 12:51:27 GMT 2023


Hi Adhemerval,

> 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.

"where possible" is the issue. Eg. for Arm USE_FFS_BUILTIN should be set from
armv5te onwards, and USE_FFSLL_BUILTIN from armv6t2 onwards on GCC14.
Other targets likely have similar issues. And targets that didn't have optimized
assembler implementations might still have the right instructions and thus
should use the builtin.

There are 2 ways to fix this properly: a configure check, or always use the builtins.

> 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.

To be clear I'm fine with a follow-on patch that removes these defines again.
It's just that in previous iterations several people wanted more accurate settings
for these defines, and it seems that could go on...

> 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).

Yes I was going to bring that up too. There are likely other functions which are rarely
used, and thus have no need to have optimized implementations or benchmarks.

Cheers,
Wilco


More information about the Libc-alpha mailing list