2 Copyright (c) 2014, Intel Corporation
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
15 * Neither the name of Intel Corporation nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <private/bionic_asm.h>
36 # define L(label) .L##label
40 # define ALIGN(n) .p2align n
43 .section .text.avx2,"ax",@progbits
45 ENTRY(__memset_chk_avx2)
46 # %rdi = dst, %rsi = byte, %rdx = n, %rcx = dst_len
49 // Fall through to memset...
50 END(__memset_chk_avx2)
55 mov $0x0101010101010101, %rcx
73 movq %rcx, -8(%rdi, %rdx)
78 movl %ecx, -4(%rdi, %rdx)
83 movw %cx, -2(%rdi, %rdx)
89 pshufd $0, %xmm0, %xmm0
91 movdqu %xmm0, -16(%rdi, %rdx)
94 movdqu %xmm0, 16(%rdi)
95 movdqu %xmm0, -32(%rdi, %rdx)
98 movdqu %xmm0, 32(%rdi)
99 movdqu %xmm0, 48(%rdi)
100 movdqu %xmm0, -64(%rdi, %rdx)
101 movdqu %xmm0, -48(%rdi, %rdx)
104 vpbroadcastb %xmm0, %ymm0
105 vmovdqu %ymm0, 64(%rdi)
106 vmovdqu %ymm0, 96(%rdi)
107 vmovdqu %ymm0, -128(%rdi, %rdx)
108 vmovdqu %ymm0, -96(%rdi, %rdx)
126 #ifdef SHARED_CACHE_SIZE
127 cmp $SHARED_CACHE_SIZE, %r8
129 cmp __x86_64_shared_cache_size(%rip), %r8
131 ja L(256bytesmore_nt)
134 L(256bytesmore_normal):
135 vmovdqa %ymm0, (%rcx)
136 vmovdqa %ymm0, 32(%rcx)
137 vmovdqa %ymm0, 64(%rcx)
138 vmovdqa %ymm0, 96(%rcx)
141 jne L(256bytesmore_normal)
146 movntdq %xmm0, (%rcx)
147 movntdq %xmm0, 16(%rcx)
148 movntdq %xmm0, 32(%rcx)
149 movntdq %xmm0, 48(%rcx)
150 movntdq %xmm0, 64(%rcx)
151 movntdq %xmm0, 80(%rcx)
152 movntdq %xmm0, 96(%rcx)
153 movntdq %xmm0, 112(%rcx)
156 jne L(256bytesmore_nt)