<commit_before>// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build ppc64 ppc64le

#include "textflag.h"

// void runtime·memclr(void*, uintptr)
TEXT runtime·memclr(SB),NOSPLIT|NOFRAME,$0-16
	MOVD	ptr+0(FP), R3
	MOVD	n+8(FP), R4
	SRADCC	$3, R4, R6	// R6 is the number of words to zero
	BEQ	bytes

	SUB	$8, R3
	MOVD	R6, CTR
	MOVDU	R0, 8(R3)
	BC	25, 0, -1(PC)	// bdnz+ $-4
	ADD	$8, R3

bytes:
	ANDCC	$7, R4, R7	// R7 is the number of bytes to zero
	BEQ	done
	SUB	$1, R3
	MOVD	R7, CTR
	MOVBU	R0, 1(R3)
	BC	25, 0, -1(PC)	// bdnz+ $-4

done:
	RET<commit_msg>runtime: memclr perf improvements on ppc64x<commit_after>// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build ppc64 ppc64le

#include "textflag.h"

// void runtime·memclr(void*, uintptr)
TEXT runtime·memclr(SB), NOSPLIT|NOFRAME, $0-16
	MOVD ptr+0(FP), R3
	MOVD n+8(FP), R4

	// Determine if there are doublewords to clear
check:
	ANDCC $7, R4, R5  // R5: leftover bytes to clear
	SRAD  $3, R4, R6  // R6: double words to clear
	CMP   R6, $0, CR1 // CR1[EQ] set if no double words

	BC     12, 6, nozerolarge // only single bytes
	MOVD   R6, CTR            // R6 = number of double words
	SRADCC $2, R6, R7         // 32 byte chunks?
	BNE    zero32setup

	// Clear double words

zero8:
	MOVD R0, 0(R3)    // double word
	ADD  $8, R3
	BC   16, 0, zero8 // dec ctr, br zero8 if ctr not 0
	BR   nozerolarge  // handle remainder

	// Prepare to clear 32 bytes at a time.

zero32setup:
	DCBTST (R3)    // prepare data cache
	MOVD   R7, CTR // number of 32 byte chunks

zero32:
	MOVD    R0, 0(R3)       // clear 4 double words
	MOVD    R0, 8(R3)
	MOVD    R0, 16(R3)
	MOVD    R0, 24(R3)
	ADD     $32, R3
	BC      16, 0, zero32   // dec ctr, br zero32 if ctr not 0
	RLDCLCC $61, R4, $3, R6 // remaining doublewords
	BEQ     nozerolarge
	MOVD    R6, CTR         // set up the CTR for doublewords
	BR      zero8

nozerolarge:
	CMP R5, $0   // any remaining bytes
	BC  4, 1, LR // ble lr

zerotail:
	MOVD R5, CTR // set up to clear tail bytes

zerotailloop:
	MOVB R0, 0(R3)           // clear single bytes
	ADD  $1, R3
	BC   16, 0, zerotailloop // dec ctr, br zerotailloop if ctr not 0
	RET
{'fraction_non_alphanumeric': 0.10782241014799154, 'fraction_numerical': 0.06638477801268498, 'mean_word_length': 2.5051851851851854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5420705', 'n_tokens_mistral': 1059, 'n_tokens_neox': 982, 'n_words': 366}