Fix whitespace issue.
[glibc.git] / sysdeps / x86_64 / multiarch / strlen-no-bsf.S
blob3e52f8165c90ea88252729a1b3c06534ac6c6e60
1 /* strlen without BSF
2    Copyright (C) 2010 Free Software Foundation, Inc.
3    Contributed by Intel Corporation.
4    This file is part of the GNU C Library.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
21 #if defined SHARED && !defined NOT_IN_libc
23 #include <sysdep.h>
25         .section .text.slow,"ax",@progbits
26 ENTRY (__strlen_no_bsf)
27         xor     %eax, %eax
28         cmpb    $0, (%rdi)
29         jz      L(exit_tail0)
30         cmpb    $0, 1(%rdi)
31         jz      L(exit_tail1)
32         cmpb    $0, 2(%rdi)
33         jz      L(exit_tail2)
34         cmpb    $0, 3(%rdi)
35         jz      L(exit_tail3)
36         cmpb    $0, 4(%rdi)
37         jz      L(exit_tail4)
38         cmpb    $0, 5(%rdi)
39         jz      L(exit_tail5)
40         cmpb    $0, 6(%rdi)
41         jz      L(exit_tail6)
42         cmpb    $0, 7(%rdi)
43         jz      L(exit_tail7)
44         cmpb    $0, 8(%rdi)
45         jz      L(exit_tail8)
46         cmpb    $0, 9(%rdi)
47         jz      L(exit_tail9)
48         cmpb    $0, 10(%rdi)
49         jz      L(exit_tail10)
50         cmpb    $0, 11(%rdi)
51         jz      L(exit_tail11)
52         cmpb    $0, 12(%rdi)
53         jz      L(exit_tail12)
54         cmpb    $0, 13(%rdi)
55         jz      L(exit_tail13)
56         cmpb    $0, 14(%rdi)
57         jz      L(exit_tail14)
58         cmpb    $0, 15(%rdi)
59         jz      L(exit_tail15)
60         pxor    %xmm0, %xmm0
61         mov     %rdi, %rcx
62         mov     %rdi, %rax
63         and     $-16, %rax
64         add     $16, %rax
65         add     $16, %rcx
67         pcmpeqb (%rax), %xmm0
68         pmovmskb %xmm0, %edx
69         pxor    %xmm1, %xmm1
70         test    %edx, %edx
71         lea     16(%rax), %rax
72         jnz     L(exit)
74         pcmpeqb (%rax), %xmm1
75         pmovmskb %xmm1, %edx
76         pxor    %xmm2, %xmm2
77         test    %edx, %edx
78         lea     16(%rax), %rax
79         jnz     L(exit)
82         pcmpeqb (%rax), %xmm2
83         pmovmskb %xmm2, %edx
84         pxor    %xmm3, %xmm3
85         test    %edx, %edx
86         lea     16(%rax), %rax
87         jnz     L(exit)
89         pcmpeqb (%rax), %xmm3
90         pmovmskb %xmm3, %edx
91         test    %edx, %edx
92         lea     16(%rax), %rax
93         jnz     L(exit)
95         pcmpeqb (%rax), %xmm0
96         pmovmskb %xmm0, %edx
97         test    %edx, %edx
98         lea     16(%rax), %rax
99         jnz     L(exit)
101         pcmpeqb (%rax), %xmm1
102         pmovmskb %xmm1, %edx
103         test    %edx, %edx
104         lea     16(%rax), %rax
105         jnz     L(exit)
107         pcmpeqb (%rax), %xmm2
108         pmovmskb %xmm2, %edx
109         test    %edx, %edx
110         lea     16(%rax), %rax
111         jnz     L(exit)
113         pcmpeqb (%rax), %xmm3
114         pmovmskb %xmm3, %edx
115         test    %edx, %edx
116         lea     16(%rax), %rax
117         jnz     L(exit)
119         pcmpeqb (%rax), %xmm0
120         pmovmskb %xmm0, %edx
121         test    %edx, %edx
122         lea     16(%rax), %rax
123         jnz     L(exit)
125         pcmpeqb (%rax), %xmm1
126         pmovmskb %xmm1, %edx
127         test    %edx, %edx
128         lea     16(%rax), %rax
129         jnz     L(exit)
131         pcmpeqb (%rax), %xmm2
132         pmovmskb %xmm2, %edx
133         test    %edx, %edx
134         lea     16(%rax), %rax
135         jnz     L(exit)
137         pcmpeqb (%rax), %xmm3
138         pmovmskb %xmm3, %edx
139         test    %edx, %edx
140         lea     16(%rax), %rax
141         jnz     L(exit)
143         pcmpeqb (%rax), %xmm0
144         pmovmskb %xmm0, %edx
145         test    %edx, %edx
146         lea     16(%rax), %rax
147         jnz     L(exit)
149         pcmpeqb (%rax), %xmm1
150         pmovmskb %xmm1, %edx
151         test    %edx, %edx
152         lea     16(%rax), %rax
153         jnz     L(exit)
155         pcmpeqb (%rax), %xmm2
156         pmovmskb %xmm2, %edx
157         test    %edx, %edx
158         lea     16(%rax), %rax
159         jnz     L(exit)
161         pcmpeqb (%rax), %xmm3
162         pmovmskb %xmm3, %edx
163         test    %edx, %edx
164         lea     16(%rax), %rax
165         jnz     L(exit)
167         and     $-0x40, %rax
168         xor     %r8d, %r8d
169 L(aligned_64):
170         pcmpeqb (%rax), %xmm0
171         pcmpeqb 16(%rax), %xmm1
172         pcmpeqb 32(%rax), %xmm2
173         pcmpeqb 48(%rax), %xmm3
174         pmovmskb %xmm0, %edx
175         pmovmskb %xmm1, %esi
176         pmovmskb %xmm2, %edi
177         pmovmskb %xmm3, %r9d
178         or      %edx, %r8d
179         or      %esi, %r8d
180         or      %edi, %r8d
181         or      %r9d, %r8d
182         lea     64(%rax), %rax
183         jz      L(aligned_64)
185         test    %edx, %edx
186         jnz     L(aligned_64_exit_16)
187         test    %esi, %esi
188         jnz     L(aligned_64_exit_32)
189         test    %edi, %edi
190         jnz     L(aligned_64_exit_48)
191 L(aligned_64_exit_64):
192         mov     %r9d, %edx
193         jmp     L(aligned_64_exit)
194 L(aligned_64_exit_48):
195         lea     -16(%rax), %rax
196         mov     %edi, %edx
197         jmp     L(aligned_64_exit)
198 L(aligned_64_exit_32):
199         lea     -32(%rax), %rax
200         mov     %esi, %edx
201         jmp     L(aligned_64_exit)
202 L(aligned_64_exit_16):
203         lea     -48(%rax), %rax
204 L(aligned_64_exit):
205 L(exit):
206         sub     %rcx, %rax
207         test    %dl, %dl
208         jz      L(exit_high)
209         test    $0x01, %dl
210         jnz     L(exit_tail0)
212         test    $0x02, %dl
213         jnz     L(exit_tail1)
215         test    $0x04, %dl
216         jnz     L(exit_tail2)
218         test    $0x08, %dl
219         jnz     L(exit_tail3)
221         test    $0x10, %dl
222         jnz     L(exit_tail4)
224         test    $0x20, %dl
225         jnz     L(exit_tail5)
227         test    $0x40, %dl
228         jnz     L(exit_tail6)
229         add     $7, %eax
230 L(exit_tail0):
231         ret
233 L(exit_high):
234         add     $8, %eax
235         test    $0x01, %dh
236         jnz     L(exit_tail0)
238         test    $0x02, %dh
239         jnz     L(exit_tail1)
241         test    $0x04, %dh
242         jnz     L(exit_tail2)
244         test    $0x08, %dh
245         jnz     L(exit_tail3)
247         test    $0x10, %dh
248         jnz     L(exit_tail4)
250         test    $0x20, %dh
251         jnz     L(exit_tail5)
253         test    $0x40, %dh
254         jnz     L(exit_tail6)
255         add     $7, %eax
256         ret
257         .p2align 4
258 L(exit_tail1):
259         add     $1, %eax
260         ret
262 L(exit_tail2):
263         add     $2, %eax
264         ret
266 L(exit_tail3):
267         add     $3, %eax
268         ret
270 L(exit_tail4):
271         add     $4, %eax
272         ret
274 L(exit_tail5):
275         add     $5, %eax
276         ret
277 L(exit_tail6):
278         add     $6, %eax
279         ret
280 L(exit_tail7):
281         add     $7, %eax
282         ret
283 L(exit_tail8):
284         add     $8, %eax
285         ret
286 L(exit_tail9):
287         add     $9, %eax
288         ret
289 L(exit_tail10):
290         add     $10, %eax
291         ret
292 L(exit_tail11):
293         add     $11, %eax
294         ret
295 L(exit_tail12):
296         add     $12, %eax
297         ret
298 L(exit_tail13):
299         add     $13, %eax
300         ret
301 L(exit_tail14):
302         add     $14, %eax
303         ret
304 L(exit_tail15):
305         add     $15, %eax
306         ret
307 END (__strlen_no_bsf)
309 #endif