src/internal/bytealg/equal_arm.s 92 lines View on github.com → Search inside
1// Copyright 2018 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.45#include "go_asm.h"6#include "textflag.h"78// memequal(a, b unsafe.Pointer, size uintptr) bool9TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-1310	MOVW	a+0(FP), R011	MOVW	b+4(FP), R212	CMP	R0, R213	B.EQ	eq14	MOVW	size+8(FP), R115	CMP	$0, R116	B.EQ	eq		// short path to handle 0-byte case17	MOVW	$ret+12(FP), R718	B	memeqbody<>(SB)19eq:20	MOVW	$1, R021	MOVB	R0, ret+12(FP)22	RET2324// memequal_varlen(a, b unsafe.Pointer) bool25TEXT runtime·memequal_varlen(SB),NOSPLIT|NOFRAME,$0-926	MOVW	a+0(FP), R027	MOVW	b+4(FP), R228	CMP	R0, R229	B.EQ	eq30	MOVW	4(R7), R1	// compiler stores size at offset 4 in the closure31	CMP	$0, R132	B.EQ	eq		// short path to handle 0-byte case33	MOVW	$ret+8(FP), R734	B	memeqbody<>(SB)35eq:36	MOVW	$1, R037	MOVB	R0, ret+8(FP)38	RET3940// Input:41// R0: data of a42// R1: length43// R2: data of b44// R7: points to return value45//46// On exit:47// R4, R5 and R6 are clobbered48TEXT memeqbody<>(SB),NOSPLIT|NOFRAME,$0-049	CMP	$1, R150	B.EQ	one		// 1-byte special case for better performance5152	CMP	$4, R153	ADD	R0, R1		// R1 is the end of the range to compare54	B.LT	byte_loop	// length < 455	AND	$3, R0, R656	CMP	$0, R657	B.NE	byte_loop	// unaligned a, use byte-wise compare (TODO: try to align a)58	AND	$3, R2, R659	CMP	$0, R660	B.NE	byte_loop	// unaligned b, use byte-wise compare61	AND	$0xfffffffc, R1, R662	// length >= 463chunk4_loop:64	MOVW.P	4(R0), R465	MOVW.P	4(R2), R566	CMP	R4, R567	B.NE	notequal68	CMP	R0, R669	B.NE	chunk4_loop70	CMP	R0, R171	B.EQ	equal		// reached the end72byte_loop:73	MOVBU.P	1(R0), R474	MOVBU.P	1(R2), R575	CMP	R4, R576	B.NE	notequal77	CMP	R0, R178	B.NE	byte_loop79equal:80	MOVW	$1, R081	MOVB	R0, (R7)82	RET83one:84	MOVBU	(R0), R485	MOVBU	(R2), R586	CMP	R4, R587	B.EQ	equal88notequal:89	MOVW	$0, R090	MOVB	R0, (R7)91	RET

Findings

✓ No findings reported for this file.

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.