131914882SAlex Richardson/* 231914882SAlex Richardson * memcmp - compare memory 331914882SAlex Richardson * 4*072a4ba8SAndrew Turner * Copyright (c) 2018-2022, Arm Limited. 5*072a4ba8SAndrew Turner * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception 631914882SAlex Richardson */ 731914882SAlex Richardson 8*072a4ba8SAndrew Turner#include "asmdefs.h" 931914882SAlex Richardson 1031914882SAlex Richardson#if __ARM_FEATURE_SVE 1131914882SAlex Richardson/* Assumptions: 1231914882SAlex Richardson * 1331914882SAlex Richardson * ARMv8-a, AArch64 1431914882SAlex Richardson * SVE Available. 1531914882SAlex Richardson */ 1631914882SAlex Richardson 1731914882SAlex RichardsonENTRY (__memcmp_aarch64_sve) 1831914882SAlex Richardson PTR_ARG (0) 1931914882SAlex Richardson PTR_ARG (1) 2031914882SAlex Richardson SIZE_ARG (2) 2131914882SAlex Richardson mov x3, 0 /* initialize off */ 2231914882SAlex Richardson 2331914882SAlex Richardson0: whilelo p0.b, x3, x2 /* while off < max */ 2431914882SAlex Richardson b.none 9f 2531914882SAlex Richardson 2631914882SAlex Richardson ld1b z0.b, p0/z, [x0, x3] /* read vectors bounded by max. */ 2731914882SAlex Richardson ld1b z1.b, p0/z, [x1, x3] 2831914882SAlex Richardson 2931914882SAlex Richardson /* Increment for a whole vector, even if we've only read a partial. 3031914882SAlex Richardson This is significantly cheaper than INCP, and since OFF is not 3131914882SAlex Richardson used after the loop it is ok to increment OFF past MAX. */ 3231914882SAlex Richardson incb x3 3331914882SAlex Richardson 3431914882SAlex Richardson cmpne p1.b, p0/z, z0.b, z1.b /* while no inequalities */ 3531914882SAlex Richardson b.none 0b 3631914882SAlex Richardson 3731914882SAlex Richardson /* Found inequality. */ 3831914882SAlex Richardson1: brkb p1.b, p0/z, p1.b /* find first such */ 3931914882SAlex Richardson lasta w0, p1, z0.b /* extract each byte */ 4031914882SAlex Richardson lasta w1, p1, z1.b 4131914882SAlex Richardson sub x0, x0, x1 /* return comparison */ 4231914882SAlex Richardson ret 4331914882SAlex Richardson 4431914882SAlex Richardson /* Found end-of-count. */ 4531914882SAlex Richardson9: mov x0, 0 /* return equality */ 4631914882SAlex Richardson ret 4731914882SAlex Richardson 4831914882SAlex RichardsonEND (__memcmp_aarch64_sve) 4931914882SAlex Richardson 5031914882SAlex Richardson#endif 5131914882SAlex Richardson 52