[PATCH 0/2] LoongArch: Add optimized functions.
Xi Ruoyao
xry111@xry111.site
Wed Sep 28 16:42:19 GMT 2022
On Wed, 2022-09-28 at 07:22 -0700, Richard Henderson wrote:
> On 9/26/22 06:49, Xi Ruoyao via Libc-alpha wrote:
> > Hi Adhemerval and Jianbo,
> >
> > I've customized string-fzi.h and string-maskoff.h for LoongArch (see
> > attachment). With them on top of Adhermerval's v5 "Improve generic
> > string routines" patch and GCC & Binutils trunk, the benchmark result
> > seems comparable with the assembly version for strchr, strcmp, and
> > strchrnul.
Hi Richard,
> There is nothing in string-maskoff.h that the compiler should not be able to produce
> itself from the generic version. Having a brief look, the compiler simply needs to be
> improved to unify two current AND patterns (which is an existing bug) and add the
> additional case for bstrins.d.
Added GCC LoongArch port maintainer into Cc:.
It's actually more complicated. Without the inline assembly in
repeat_bytes(), the compiler does not hoist the 4-instruction 64-bit
immediate load sequence out of a loop for "some reason I don't know
yet".
> Similarly, there is nothing in string-fzi.h that should not be gotten from longlong.h;
> your only changes are to use __builtin_clz, which longlong.h exports as count_trailing_zeros.
No, it does not. By default longlong.h uses a table driven approach for
count_{trailing,leading}_zeros. I can add __loongarch__ (or
__loongarch_lp64) into longlong.h though. IIUC I need to submit the
change to GCC, then Glibc merges longlong.h from GCC, right?
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the Libc-alpha
mailing list