glibc/sysdeps/x86_64/multiarch/memset-avx512-no-vzeroupper.S

199 lines
4.3 KiB
ArmAsm
Raw Normal View History

/* memset optimized with AVX512 for KNL hardware.
Copyright (C) 2015-2021 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
Prefer https to http for gnu.org and fsf.org URLs Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
Require binutils 2.24 to build x86-64 glibc [BZ #20139] If assembler doesn't support AVX512DQ, _dl_runtime_resolve_avx is used to save the first 8 vector registers, which only saves the lower 256 bits of vector register, for lazy binding. When it is called on AVX512 platform, the upper 256 bits of ZMM registers are clobbered. Parameters passed in ZMM registers will be wrong when the function is called the first time. This patch requires binutils 2.24, whose assembler can store and load ZMM registers, to build x86-64 glibc. Since mathvec library needs assembler support for AVX512DQ, we disable mathvec if assembler doesn't support AVX512DQ. [BZ #20139] * config.h.in (HAVE_AVX512_ASM_SUPPORT): Renamed to ... (HAVE_AVX512DQ_ASM_SUPPORT): This. * sysdeps/x86_64/configure.ac: Require assembler from binutils 2.24 or above. (HAVE_AVX512_ASM_SUPPORT): Removed. (HAVE_AVX512DQ_ASM_SUPPORT): New. * sysdeps/x86_64/configure: Regenerated. * sysdeps/x86_64/dl-trampoline.S: Make HAVE_AVX512_ASM_SUPPORT check unconditional. * sysdeps/x86_64/multiarch/ifunc-impl-list.c: Likewise. * sysdeps/x86_64/multiarch/memcpy.S: Likewise. * sysdeps/x86_64/multiarch/memcpy_chk.S: Likewise. * sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S: Likewise. * sysdeps/x86_64/multiarch/memmove-avx512-unaligned-erms.S: Likewise. * sysdeps/x86_64/multiarch/memmove.S: Likewise. * sysdeps/x86_64/multiarch/memmove_chk.S: Likewise. * sysdeps/x86_64/multiarch/mempcpy.S: Likewise. * sysdeps/x86_64/multiarch/mempcpy_chk.S: Likewise. * sysdeps/x86_64/multiarch/memset-avx512-no-vzeroupper.S: Likewise. * sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S: Likewise. * sysdeps/x86_64/multiarch/memset.S: Likewise. * sysdeps/x86_64/multiarch/memset_chk.S: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_d_cos8_core_avx512.S: Check HAVE_AVX512DQ_ASM_SUPPORT instead of HAVE_AVX512_ASM_SUPPORT. * sysdeps/x86_64/fpu/multiarch/svml_d_exp8_core_avx512.S: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_d_log8_core_avx512.S: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_d_pow8_core_avx512.S: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_d_sin8_core_avx512.S: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_d_sincos8_core_avx512.: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_s_cosf16_core_avx512.S: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_s_expf16_core_avx512.S: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_s_logf16_core_avx512.S: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_s_powf16_core_avx512.S: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_s_sincosf16_core_avx51: Likewise. * sysdeps/x86_64/fpu/multiarch/svml_s_sinf16_core_avx512.S: Likewise.
2016-07-01 12:54:43 +00:00
#if IS_IN (libc)
#include "asm-syntax.h"
#ifndef MEMSET
# define MEMSET __memset_avx512_no_vzeroupper
# define MEMSET_CHK __memset_chk_avx512_no_vzeroupper
#endif
.section .text.avx512,"ax",@progbits
#if defined PIC
ENTRY (MEMSET_CHK)
cmp %RDX_LP, %RCX_LP
jb HIDDEN_JUMPTARGET (__chk_fail)
END (MEMSET_CHK)
#endif
ENTRY (MEMSET)
# ifdef __ILP32__
/* Clear the upper 32 bits. */
mov %edx, %edx
# endif
vpxor %xmm0, %xmm0, %xmm0
vmovd %esi, %xmm1
lea (%rdi, %rdx), %rsi
mov %rdi, %rax
vpshufb %xmm0, %xmm1, %xmm0
cmp $16, %rdx
jb L(less_16bytes)
cmp $512, %rdx
vbroadcastss %xmm0, %zmm2
ja L(512bytesormore)
cmp $256, %rdx
jb L(less_256bytes)
vmovups %zmm2, (%rdi)
vmovups %zmm2, 0x40(%rdi)
vmovups %zmm2, 0x80(%rdi)
vmovups %zmm2, 0xC0(%rdi)
vmovups %zmm2, -0x100(%rsi)
vmovups %zmm2, -0xC0(%rsi)
vmovups %zmm2, -0x80(%rsi)
vmovups %zmm2, -0x40(%rsi)
ret
L(less_256bytes):
cmp $128, %dl
jb L(less_128bytes)
vmovups %zmm2, (%rdi)
vmovups %zmm2, 0x40(%rdi)
vmovups %zmm2, -0x80(%rsi)
vmovups %zmm2, -0x40(%rsi)
ret
L(less_128bytes):
cmp $64, %dl
jb L(less_64bytes)
vmovups %zmm2, (%rdi)
vmovups %zmm2, -0x40(%rsi)
ret
L(less_64bytes):
cmp $32, %dl
jb L(less_32bytes)
vmovdqu %ymm2, (%rdi)
vmovdqu %ymm2, -0x20(%rsi)
ret
L(less_32bytes):
vmovdqu %xmm0, (%rdi)
vmovdqu %xmm0, -0x10(%rsi)
ret
L(less_16bytes):
cmp $8, %dl
jb L(less_8bytes)
vmovq %xmm0, (%rdi)
vmovq %xmm0, -0x08(%rsi)
ret
L(less_8bytes):
vmovd %xmm0, %ecx
cmp $4, %dl
jb L(less_4bytes)
mov %ecx, (%rdi)
mov %ecx, -0x04(%rsi)
ret
L(less_4bytes):
cmp $2, %dl
jb L(less_2bytes)
mov %cx, (%rdi)
mov %cx, -0x02(%rsi)
ret
L(less_2bytes):
cmp $1, %dl
jb L(less_1bytes)
mov %cl, (%rdi)
L(less_1bytes):
ret
L(512bytesormore):
mov __x86_shared_cache_size_half(%rip), %rcx
cmp %rcx, %rdx
ja L(preloop_large)
cmp $1024, %rdx
ja L(1024bytesormore)
vmovups %zmm2, (%rdi)
vmovups %zmm2, 0x40(%rdi)
vmovups %zmm2, 0x80(%rdi)
vmovups %zmm2, 0xC0(%rdi)
vmovups %zmm2, 0x100(%rdi)
vmovups %zmm2, 0x140(%rdi)
vmovups %zmm2, 0x180(%rdi)
vmovups %zmm2, 0x1C0(%rdi)
vmovups %zmm2, -0x200(%rsi)
vmovups %zmm2, -0x1C0(%rsi)
vmovups %zmm2, -0x180(%rsi)
vmovups %zmm2, -0x140(%rsi)
vmovups %zmm2, -0x100(%rsi)
vmovups %zmm2, -0xC0(%rsi)
vmovups %zmm2, -0x80(%rsi)
vmovups %zmm2, -0x40(%rsi)
ret
/* Align on 64 and loop with aligned stores. */
L(1024bytesormore):
sub $0x100, %rsi
vmovups %zmm2, (%rax)
and $-0x40, %rdi
add $0x40, %rdi
L(gobble_256bytes_loop):
vmovaps %zmm2, (%rdi)
vmovaps %zmm2, 0x40(%rdi)
vmovaps %zmm2, 0x80(%rdi)
vmovaps %zmm2, 0xC0(%rdi)
add $0x100, %rdi
cmp %rsi, %rdi
jb L(gobble_256bytes_loop)
vmovups %zmm2, (%rsi)
vmovups %zmm2, 0x40(%rsi)
vmovups %zmm2, 0x80(%rsi)
vmovups %zmm2, 0xC0(%rsi)
ret
/* Align on 128 and loop with non-temporal stores. */
L(preloop_large):
and $-0x80, %rdi
add $0x80, %rdi
vmovups %zmm2, (%rax)
vmovups %zmm2, 0x40(%rax)
sub $0x200, %rsi
L(gobble_512bytes_nt_loop):
vmovntdq %zmm2, (%rdi)
vmovntdq %zmm2, 0x40(%rdi)
vmovntdq %zmm2, 0x80(%rdi)
vmovntdq %zmm2, 0xC0(%rdi)
vmovntdq %zmm2, 0x100(%rdi)
vmovntdq %zmm2, 0x140(%rdi)
vmovntdq %zmm2, 0x180(%rdi)
vmovntdq %zmm2, 0x1C0(%rdi)
add $0x200, %rdi
cmp %rsi, %rdi
jb L(gobble_512bytes_nt_loop)
sfence
vmovups %zmm2, (%rsi)
vmovups %zmm2, 0x40(%rsi)
vmovups %zmm2, 0x80(%rsi)
vmovups %zmm2, 0xC0(%rsi)
vmovups %zmm2, 0x100(%rsi)
vmovups %zmm2, 0x140(%rsi)
vmovups %zmm2, 0x180(%rsi)
vmovups %zmm2, 0x1C0(%rsi)
ret
END (MEMSET)
#endif