52 lines · plain
1/*2 * memcmp - compare memory3 *4 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5 * See https://llvm.org/LICENSE.txt for license information.6 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7 */8 9#if __ARM_FEATURE_SVE10/* Assumptions:11 *12 * ARMv8-a, AArch6413 * SVE Available.14 */15 16 .arch armv8-a+sve17 .text18 19 .globl __memcmp_aarch64_sve20 .type __memcmp_aarch64_sve, %function21 .p2align 422__memcmp_aarch64_sve:23 mov x3, 0 /* initialize off */24 250: whilelo p0.b, x3, x2 /* while off < max */26 b.none 9f27 28 ld1b z0.b, p0/z, [x0, x3] /* read vectors bounded by max. */29 ld1b z1.b, p0/z, [x1, x3]30 31 /* Increment for a whole vector, even if we've only read a partial.32 This is significantly cheaper than INCP, and since OFF is not33 used after the loop it is ok to increment OFF past MAX. */34 incb x335 36 cmpne p1.b, p0/z, z0.b, z1.b /* while no inequalities */37 b.none 0b38 39 /* Found inequality. */401: brkb p1.b, p0/z, p1.b /* find first such */41 lasta w0, p1, z0.b /* extract each byte */42 lasta w1, p1, z1.b43 sub x0, x0, x1 /* return comparison */44 ret45 46 /* Found end-of-count. */479: mov x0, 0 /* return equality */48 ret49 50 .size __memcmp_aarch64_sve, . - __memcmp_aarch64_sve51#endif52