[PATCH 1/2] string: add find_ne_all to string-fza.h

Wilco Dijkstra Wilco.Dijkstra@arm.com
Thu Aug 13 21:58:15 GMT 2026


Hi Matt,

+static __always_inline find_t
+find_ne_all (op_t x1, op_t x2)
+{
+  op_t m = repeat_bytes (0x7f);
+  op_t ne = x1 ^ x2;
+  return (((ne & m) + m) | ne) & ~m;
+}

That's a lot of code to do very little... In fact we don't need it if
HAVE_BITOPTS_WORKING is set since clz/ctz work fine on (x1 ^ x2).

The related find_zero_ne_all() has the same issue - we can just do
(x1 ^ x2) | find_zero_all (x1) if HAVE_BITOPTS_WORKING.

And we could remove the unnecessary code from string-fzi.h if all targets
now have working stdc_leading_zeros/stdc_trailing_zeros.

Cheers,
Wilco


More information about the Libc-alpha mailing list