diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-02-07 05:55:15 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-02-08 15:58:56 -0800 |
commit | 3d9f171bfb5325bd5f427e9fc386453358c6e840 (patch) | |
tree | 5caeddafa6cb494bbe102c34f7f2ee630f5d83cf /sysdeps/x86_64/memset.S | |
parent | dc98eeeb952f59bdbd51da0409e732756fe30170 (diff) | |
download | glibc-3d9f171bfb5325bd5f427e9fc386453358c6e840.tar.gz glibc-3d9f171bfb5325bd5f427e9fc386453358c6e840.tar.xz glibc-3d9f171bfb5325bd5f427e9fc386453358c6e840.zip |
x86-64: Optimize bzero
memset with zero as the value to set is by far the majority value (99%+ for Python3 and GCC). bzero can be slightly more optimized for this case by using a zero-idiom xor for broadcasting the set value to a register (vector or GPR). Co-developed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Diffstat (limited to 'sysdeps/x86_64/memset.S')
-rw-r--r-- | sysdeps/x86_64/memset.S | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S index 3f0517bbfc..af26e9cedc 100644 --- a/sysdeps/x86_64/memset.S +++ b/sysdeps/x86_64/memset.S @@ -35,6 +35,9 @@ punpcklwd %xmm0, %xmm0; \ pshufd $0, %xmm0, %xmm0 +# define BZERO_ZERO_VEC0() \ + pxor %xmm0, %xmm0 + # define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \ movd d, %xmm0; \ pshufd $0, %xmm0, %xmm0; \ @@ -53,6 +56,10 @@ # define MEMSET_SYMBOL(p,s) memset #endif +#ifndef BZERO_SYMBOL +# define BZERO_SYMBOL(p,s) __bzero +#endif + #ifndef WMEMSET_SYMBOL # define WMEMSET_CHK_SYMBOL(p,s) p # define WMEMSET_SYMBOL(p,s) __wmemset @@ -63,6 +70,7 @@ libc_hidden_builtin_def (memset) #if IS_IN (libc) +weak_alias (__bzero, bzero) libc_hidden_def (__wmemset) weak_alias (__wmemset, wmemset) libc_hidden_weak (wmemset) |