2 * Copyright (C) 2004, 2007-2010, 2011-2014 Synopsys, Inc. All rights reserved.
4 * SPDX-License-Identifier: GPL-2.0+
8 * This is optimized primarily for the ARC700.
9 * It would be possible to speed up the loops by one cycle / word
10 * respective one cycle / byte by forcing double source 1 alignment, unrolling
11 * by a factor of two, and speculatively loading the second word / byte of
12 * source 1; however, that would increase the overhead for loop setup / finish,
13 * and strcmp might often terminate early.
21 brne %r2, 0, .Lcharloop
22 mov_s %r12, 0x01010101
32 breq %r2 ,%r3, .Lwordloop
33 #ifdef __LITTLE_ENDIAN__
34 xor %r0, %r2, %r3 /* mask for difference */
36 bic_s %r0, %r0, %r1 /* mask for least significant difference bit */
38 xor %r0, %r5, %r1 /* mask for least significant difference byte */
41 #endif /* _ENDIAN__ */
48 #ifdef __LITTLE_ENDIAN__
50 xor %r0, %r2, %r3 /* mask for difference */
51 or %r0, %r0, %r4 /* or in zero indicator */
53 bic_s %r0, %r0, %r1 /* mask for least significant difference bit */
55 xor %r0, %r5, %r1 /* mask for least significant difference byte */
62 #else /* __BIG_ENDIAN__ */
64 * The zero-detection above can mis-detect 0x01 bytes as zeroes
65 * because of carry-propagateion from a lower significant zero byte.
66 * We can compensate for this by checking that bit0 is zero.
67 * This compensation is not necessary in the step where we
68 * get a low estimate for r2, because in any affected bytes
69 * we already have 0x00 or 0x01, which will remain unchanged
70 * when bit 7 is cleared.
76 bic_s %r2, %r2, %r0 /* get low estimate for r2 and get ... */
77 bic_s %r0, %r0, %r1 /* <this is the adjusted mask for zeros> */
78 or_s %r3, %r3, %r0 /* ... high estimate r3 so that r2 > r3 will */
79 cmp_s %r3, %r2 /* ... be independent of trailing garbage */
80 or_s %r2, %r2, %r0 /* likewise for r3 > r2 */
82 rlc %r0, 0 /* r0 := r2 > r3 ? 1 : 0 */
86 #endif /* _ENDIAN__ */
94 breq %r2, %r3, .Lcharloop