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