~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to sysdeps/x86_64/wcslen.S

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Optimized wcslen for x86-64 with SSE2.
 
2
   Copyright (C) 2011 Free Software Foundation, Inc.
 
3
   Contributed by Intel Corporation.
 
4
   This file is part of the GNU C Library.
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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.  */
 
20
 
 
21
#include <sysdep.h>
 
22
 
 
23
        .text
 
24
ENTRY (__wcslen)
 
25
        cmpl    $0, (%rdi)
 
26
        jz      L(exit_tail0)
 
27
        cmpl    $0, 4(%rdi)
 
28
        jz      L(exit_tail1)
 
29
        cmpl    $0, 8(%rdi)
 
30
        jz      L(exit_tail2)
 
31
        cmpl    $0, 12(%rdi)
 
32
        jz      L(exit_tail3)
 
33
        cmpl    $0, 16(%rdi)
 
34
        jz      L(exit_tail4)
 
35
        cmpl    $0, 20(%rdi)
 
36
        jz      L(exit_tail5)
 
37
        cmpl    $0, 24(%rdi)
 
38
        jz      L(exit_tail6)
 
39
        cmpl    $0, 28(%rdi)
 
40
        jz      L(exit_tail7)
 
41
 
 
42
        pxor    %xmm0, %xmm0
 
43
 
 
44
        lea     32(%rdi), %rax
 
45
        lea     16(%rdi), %rcx
 
46
        and     $-16, %rax
 
47
 
 
48
        pcmpeqd (%rax), %xmm0
 
49
        pmovmskb %xmm0, %edx
 
50
        pxor    %xmm1, %xmm1
 
51
        test    %edx, %edx
 
52
        lea     16(%rax), %rax
 
53
        jnz     L(exit)
 
54
 
 
55
        pcmpeqd (%rax), %xmm1
 
56
        pmovmskb %xmm1, %edx
 
57
        pxor    %xmm2, %xmm2
 
58
        test    %edx, %edx
 
59
        lea     16(%rax), %rax
 
60
        jnz     L(exit)
 
61
 
 
62
        pcmpeqd (%rax), %xmm2
 
63
        pmovmskb %xmm2, %edx
 
64
        pxor    %xmm3, %xmm3
 
65
        test    %edx, %edx
 
66
        lea     16(%rax), %rax
 
67
        jnz     L(exit)
 
68
 
 
69
        pcmpeqd (%rax), %xmm3
 
70
        pmovmskb %xmm3, %edx
 
71
        test    %edx, %edx
 
72
        lea     16(%rax), %rax
 
73
        jnz     L(exit)
 
74
 
 
75
        pcmpeqd (%rax), %xmm0
 
76
        pmovmskb %xmm0, %edx
 
77
        test    %edx, %edx
 
78
        lea     16(%rax), %rax
 
79
        jnz     L(exit)
 
80
 
 
81
        pcmpeqd (%rax), %xmm1
 
82
        pmovmskb %xmm1, %edx
 
83
        test    %edx, %edx
 
84
        lea     16(%rax), %rax
 
85
        jnz     L(exit)
 
86
 
 
87
        pcmpeqd (%rax), %xmm2
 
88
        pmovmskb %xmm2, %edx
 
89
        test    %edx, %edx
 
90
        lea     16(%rax), %rax
 
91
        jnz     L(exit)
 
92
 
 
93
        pcmpeqd (%rax), %xmm3
 
94
        pmovmskb %xmm3, %edx
 
95
        test    %edx, %edx
 
96
        lea     16(%rax), %rax
 
97
        jnz     L(exit)
 
98
 
 
99
        pcmpeqd (%rax), %xmm0
 
100
        pmovmskb %xmm0, %edx
 
101
        test    %edx, %edx
 
102
        lea     16(%rax), %rax
 
103
        jnz     L(exit)
 
104
 
 
105
        pcmpeqd (%rax), %xmm1
 
106
        pmovmskb %xmm1, %edx
 
107
        test    %edx, %edx
 
108
        lea     16(%rax), %rax
 
109
        jnz     L(exit)
 
110
 
 
111
        pcmpeqd (%rax), %xmm2
 
112
        pmovmskb %xmm2, %edx
 
113
        test    %edx, %edx
 
114
        lea     16(%rax), %rax
 
115
        jnz     L(exit)
 
116
 
 
117
        pcmpeqd (%rax), %xmm3
 
118
        pmovmskb %xmm3, %edx
 
119
        test    %edx, %edx
 
120
        lea     16(%rax), %rax
 
121
        jnz     L(exit)
 
122
 
 
123
        and     $-0x40, %rax
 
124
 
 
125
        .p2align 4
 
126
L(aligned_64_loop):
 
127
        movaps  (%rax), %xmm0
 
128
        movaps  16(%rax), %xmm1
 
129
        movaps  32(%rax), %xmm2
 
130
        movaps  48(%rax), %xmm6
 
131
 
 
132
        pminub  %xmm1, %xmm0
 
133
        pminub  %xmm6, %xmm2
 
134
        pminub  %xmm0, %xmm2
 
135
        pcmpeqd %xmm3, %xmm2
 
136
        pmovmskb %xmm2, %edx
 
137
        test    %edx, %edx
 
138
        lea     64(%rax), %rax
 
139
        jz      L(aligned_64_loop)
 
140
 
 
141
        pcmpeqd -64(%rax), %xmm3
 
142
        pmovmskb %xmm3, %edx
 
143
        test    %edx, %edx
 
144
        lea     48(%rcx), %rcx
 
145
        jnz     L(exit)
 
146
 
 
147
        pcmpeqd %xmm1, %xmm3
 
148
        pmovmskb %xmm3, %edx
 
149
        test    %edx, %edx
 
150
        lea     -16(%rcx), %rcx
 
151
        jnz     L(exit)
 
152
 
 
153
        pcmpeqd -32(%rax), %xmm3
 
154
        pmovmskb %xmm3, %edx
 
155
        test    %edx, %edx
 
156
        lea     -16(%rcx), %rcx
 
157
        jnz     L(exit)
 
158
 
 
159
        pcmpeqd %xmm6, %xmm3
 
160
        pmovmskb %xmm3, %edx
 
161
        test    %edx, %edx
 
162
        lea     -16(%rcx), %rcx
 
163
        jnz     L(exit)
 
164
 
 
165
        jmp     L(aligned_64_loop)
 
166
 
 
167
        .p2align 4
 
168
L(exit):
 
169
        sub     %rcx, %rax
 
170
        shr     $2, %rax
 
171
        test    %dl, %dl
 
172
        jz      L(exit_high)
 
173
 
 
174
        mov     %dl, %cl
 
175
        and     $15, %cl
 
176
        jz      L(exit_1)
 
177
        ret
 
178
 
 
179
        .p2align 4
 
180
L(exit_high):
 
181
        mov     %dh, %ch
 
182
        and     $15, %ch
 
183
        jz      L(exit_3)
 
184
        add     $2, %rax
 
185
        ret
 
186
 
 
187
        .p2align 4
 
188
L(exit_1):
 
189
        add     $1, %rax
 
190
        ret
 
191
 
 
192
        .p2align 4
 
193
L(exit_3):
 
194
        add     $3, %rax
 
195
        ret
 
196
 
 
197
        .p2align 4
 
198
L(exit_tail0):
 
199
        xor     %rax, %rax
 
200
        ret
 
201
 
 
202
        .p2align 4
 
203
L(exit_tail1):
 
204
        mov     $1, %rax
 
205
        ret
 
206
 
 
207
        .p2align 4
 
208
L(exit_tail2):
 
209
        mov     $2, %rax
 
210
        ret
 
211
 
 
212
        .p2align 4
 
213
L(exit_tail3):
 
214
        mov     $3, %rax
 
215
        ret
 
216
 
 
217
        .p2align 4
 
218
L(exit_tail4):
 
219
        mov     $4, %rax
 
220
        ret
 
221
 
 
222
        .p2align 4
 
223
L(exit_tail5):
 
224
        mov     $5, %rax
 
225
        ret
 
226
 
 
227
        .p2align 4
 
228
L(exit_tail6):
 
229
        mov     $6, %rax
 
230
        ret
 
231
 
 
232
        .p2align 4
 
233
L(exit_tail7):
 
234
        mov     $7, %rax
 
235
        ret
 
236
 
 
237
END (__wcslen)
 
238
 
 
239
weak_alias(__wcslen, wcslen)