1/* SPDX-License-Identifier: GPL-2.0 */
2
3/*
4 * memcmp for PowerPC32
5 *
6 * Copyright (C) 1996 Paul Mackerras.
7 *
8 */
9
10#include <asm/ppc_asm.h>
11#include <asm/export.h>
12
13	.text
14
15_GLOBAL(memcmp)
16	srawi.	r7, r5, 2		/* Divide len by 4 */
17	mr	r6, r3
18	beq-	3f
19	mtctr	r7
20	li	r7, 0
211:	lwzx	r3, r6, r7
22	lwzx	r0, r4, r7
23	addi	r7, r7, 4
24	cmplw	cr0, r3, r0
25	bdnzt	eq, 1b
26	bne	5f
273:	andi.	r3, r5, 3
28	beqlr
29	cmplwi	cr1, r3, 2
30	blt-	cr1, 4f
31	lhzx	r3, r6, r7
32	lhzx	r0, r4, r7
33	addi	r7, r7, 2
34	subf.	r3, r0, r3
35	beqlr	cr1
36	bnelr
374:	lbzx	r3, r6, r7
38	lbzx	r0, r4, r7
39	subf.	r3, r0, r3
40	blr
415:	li	r3, 1
42	bgtlr
43	li	r3, -1
44	blr
45EXPORT_SYMBOL(memcmp)
46