[PATCH v12 18/31] arm: Add string-fza.h
Szabolcs Nagy
szabolcs.nagy@arm.com
Mon Feb 20 16:12:46 GMT 2023
The 02/20/2023 11:01, Adhemerval Zanella Netto wrote:
>
>
> On 20/02/23 10:45, Szabolcs Nagy wrote:
> > The 02/20/2023 13:24, Szabolcs Nagy via Libc-alpha wrote:
> >> The 02/02/2023 15:11, Adhemerval Zanella via Libc-alpha wrote:
> >>> +static __always_inline find_t
> >>> +find_zero_all (op_t x)
> >>> +{
> >>> + /* Use unsigned saturated subtraction from 1 in each byte.
> >>> + That leaves 1 for every byte that was zero. */
> >>> + op_t ones = repeat_bytes (0x01);
> >>> + return __builtin_arm_uqsub8 (ones, x);
> >>> +}
> >>
> >> __builtin_arm_uqsub8 is only available >=gcc-10
> >>
> >> so now the build fails with gcc-9
> >>
> >> ../sysdeps/arm/armv6t2/string-fza.h:36:10: error: implicit declaration of function ‘__builtin_arm_uqsub8’; did you mean ‘__builtin_arm_stc’? [-Werror=implicit-function-declaration]
> >> 36 | return __builtin_arm_uqsub8 (ones, x);
> >>
> >> so this code should be conditional on gcc version.
> >>
> >
> > i think
> >
> > asm ("uqsub8 %0, %0, %1" : "+r" (ones) : "r" (x));
> >
> > should be a good fallback (untested).
>
> This is what we have on v7:
>
> static __always_inline op_t
> find_zero_all (op_t x)
> {
> /* Use unsigned saturated subtraction from 1 in each byte.
> That leaves 1 for every byte that was zero. */
> op_t ret, ones = repeat_bytes (0x01);
> asm ("uqsub8 %0,%1,%2" : "=r"(ret) : "r"(ones), "r"(x));
> return ret;
> }
>
> Maybe extend with:
>
> static __always_inline op_t
> find_zero_all (op_t x)
> {
> op_t ones = repeat_bytes (0x01);
> #if __GNUC_PREREQ (10, 0)
> return __builtin_arm_uqsub8 (ones, x);
> #else
> op_t ret;
> asm ("uqsub8 %0,%1,%2" : "=r"(ret) : "r"(ones), "r"(x));
> return ret;
> #endif
> }
yes this looks good to me.
More information about the Libc-alpha
mailing list