1/* 2 * memcmp - compare memory 3 * 4 * Copyright (c) 2018-2022, Arm Limited. 5 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception 6 */ 7 8#include "asmdefs.h" 9 10.arch armv8-a+sve 11 12/* Assumptions: 13 * 14 * ARMv8-a, AArch64 15 * SVE Available. 16 */ 17 18ENTRY (__memcmp_aarch64_sve) 19 mov x3, 0 /* initialize off */ 20 210: whilelo p0.b, x3, x2 /* while off < max */ 22 b.none 9f 23 24 ld1b z0.b, p0/z, [x0, x3] /* read vectors bounded by max. */ 25 ld1b z1.b, p0/z, [x1, x3] 26 27 /* Increment for a whole vector, even if we've only read a partial. 28 This is significantly cheaper than INCP, and since OFF is not 29 used after the loop it is ok to increment OFF past MAX. */ 30 incb x3 31 32 cmpne p1.b, p0/z, z0.b, z1.b /* while no inequalities */ 33 b.none 0b 34 35 /* Found inequality. */ 361: brkb p1.b, p0/z, p1.b /* find first such */ 37 lasta w0, p1, z0.b /* extract each byte */ 38 lasta w1, p1, z1.b 39 sub x0, x0, x1 /* return comparison */ 40 ret 41 42 /* Found end-of-count. */ 439: mov x0, 0 /* return equality */ 44 ret 45 46END (__memcmp_aarch64_sve) 47