1 /* Optimized strncmp implementation for PowerPC476.
2 Copyright (C) 2010-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
24 r0:temp return equality
25 r3:source1 address, return equality
29 Implementation description
30 Touch in 3 lines of D-cache.
31 If source1 or source2 is unaligned copy 0-3 bytes to make source1 aligned
32 Check 2 words from src1 and src2. If unequal jump to end and
33 return src1 > src2 or src1 < src2.
34 If null check bytes before null and then jump to end and
35 return src1 > src2, src1 < src2 or src1 = src2.
36 If count = zero check bytes before zero counter and then jump to end and
37 return src1 > src2, src1 < src2 or src1 = src2.
38 If src1 = src2 and no null, repeat. */
46 beq L(prebyte_count_loop)
48 beq L(prebyte_count_loop)
51 ble L(preword2_count_loop)
54 L(preword2_count_loop):
56 beq L(prebyte_count_loop)
76 bdnz L(word2_count_loop)
78 L(prebyte_count_loop):
92 bdnz L(byte_count_loop)
103 rlwinm r12,r12,3,0,31
113 rlwinm r12,r12,3,0,31
128 libc_hidden_builtin_def (strncmp)