[PATCH v12 03/31] Add string vectorized find and detection functions

Richard Henderson richard.henderson@linaro.org
Fri Feb 3 00:24:12 GMT 2023


On 2/2/23 08:11, Adhemerval Zanella wrote:
> +/* With similar caveats, identify zero bytes in X1 and bytes that are
> +   not equal between in X1 and X2.  */
> +static __always_inline find_t
> +find_zero_ne_low (op_t x1, op_t x2)
> +{
> +  return (~find_zero_eq_low (x1, x2)) + 1;
> +}

This is no longer used, and suspected buggy.  Duh, I now see why it's buggy -- it's 
inverting both zero comparison and eq comparison -- we wanted to invert only eq.

Let's remove this rather than attempting to fix.  I suspect it'll work out very similar to 
our existing find_zero_ne_all().


> +/* Similarly, but perform the search for byte equality between X1 and X2.  */
> +static __always_inline unsigned int
> +index_first_zero (op_t x1, op_t x2)
> +{
> +  if (__BYTE_ORDER == __LITTLE_ENDIAN)
> +    x1 = find_zero_low (x1, x2);
> +  else
> +    x1 = find_zero_all (x1, x2);
> +  return index_first (x1);
> +}
...
> +/* Similarly, but search for the last zero within X.  */
> +static __always_inline unsigned int
> +index_last_zero (op_t x)
> +{
> +  return index_last (find_zero_all (x));
> +}

Why did this lose the __BYTE_ORDER test?  It should be the inverse of index_first_zero.


> +static __always_inline unsigned int
> +index_last_eq (op_t x1, op_t x2)
> +{
> +  return index_last_zero (x1 ^ x2);
> +}

Similarly.


r~


More information about the Libc-alpha mailing list