about summary refs log tree commit diff
path: root/sysdeps/loongarch/lp64/multiarch/memset.c
diff options
context:
space:
mode:
authordengjianbo <dengjianbo@loongson.cn>2023-08-28 10:08:38 +0800
committercaiyinyu <caiyinyu@loongson.cn>2023-08-29 10:35:38 +0800
commit1b1e9b7c10f27947a7cddddf95701ec8030167a6 (patch)
treebe3b9a89503dfcd1579cb1d09b1a292055bfa478 /sysdeps/loongarch/lp64/multiarch/memset.c
parent55e84dc6edc074f0f87a28bafce3249dfed4b201 (diff)
downloadglibc-1b1e9b7c10f27947a7cddddf95701ec8030167a6.tar.gz
glibc-1b1e9b7c10f27947a7cddddf95701ec8030167a6.tar.xz
glibc-1b1e9b7c10f27947a7cddddf95701ec8030167a6.zip
LoongArch: Add ifunc support for memset{aligned, unaligned, lsx, lasx}
According to glibc memset microbenchmark test results, for LSX and LASX
versions, A few cases with length less than 8 experience performace
degradation, overall, the LASX version could reduce the runtime about
15% - 75%, LSX version could reduce the runtime about 15%-50%.

The unaligned version uses unaligned memmory access to set data which
length is less than 64 and make address aligned with 8. For this part,
the performace is better than aligned version. Comparing with the generic
version, the performance is close when the length is larger than 128. When
the length is 8-128, the unaligned version could reduce the runtime about
30%-70%, the aligned version could reduce the runtime about 20%-50%.
Diffstat (limited to 'sysdeps/loongarch/lp64/multiarch/memset.c')
-rw-r--r--sysdeps/loongarch/lp64/multiarch/memset.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/sysdeps/loongarch/lp64/multiarch/memset.c b/sysdeps/loongarch/lp64/multiarch/memset.c
new file mode 100644
index 0000000000..3ff60d8ac7
--- /dev/null
+++ b/sysdeps/loongarch/lp64/multiarch/memset.c
@@ -0,0 +1,37 @@
+/* Multiple versions of memset.
+   All versions must be listed in ifunc-impl-list.c.
+   Copyright (C) 2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* Define multiple versions only for the definition in libc.  */
+#if IS_IN (libc)
+# define memset __redirect_memset
+# include <string.h>
+# undef memset
+
+# define SYMBOL_NAME memset
+# include "ifunc-lasx.h"
+
+libc_ifunc_redirected (__redirect_memset, memset,
+		       IFUNC_SELECTOR ());
+
+# ifdef SHARED
+__hidden_ver1 (memset, __GI_memset, __redirect_memset)
+  __attribute__ ((visibility ("hidden"))) __attribute_copy__ (memset);
+# endif
+
+#endif