aboutsummaryrefslogtreecommitdiff
path: root/string/aarch64/memcmp-sve.S
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-08-26 16:04:20 -0300
committerSzabolcs Nagy <30925343+nsz-arm@users.noreply.github.com>2019-08-28 12:05:23 +0100
commitfe7ca84adb9f1119734995bf2415373ed3970757 (patch)
tree9460708a2b5e5b323f9b667755cd817ef0e22d13 /string/aarch64/memcmp-sve.S
parent10c7a2dbfcbb1334a2789a9a7dce1cad076c4742 (diff)
downloadarm-optimized-routines-fe7ca84adb9f1119734995bf2415373ed3970757.tar.gz
Import aarch64 sve memcmp
The only difference is changing the symbol name from memcmp to __memcmp_aarch64_sve.
Diffstat (limited to 'string/aarch64/memcmp-sve.S')
-rw-r--r--string/aarch64/memcmp-sve.S48
1 files changed, 48 insertions, 0 deletions
diff --git a/string/aarch64/memcmp-sve.S b/string/aarch64/memcmp-sve.S
new file mode 100644
index 0000000..d4f6026
--- /dev/null
+++ b/string/aarch64/memcmp-sve.S
@@ -0,0 +1,48 @@
+/*
+ * memcmp - compare memory
+ *
+ * Copyright (c) 2018, Arm Limited.
+ * SPDX-License-Identifier: MIT
+ */
+
+/* Assumptions:
+ *
+ * ARMv8-a, AArch64
+ * SVE Available.
+ */
+
+ .arch armv8-a+sve
+ .text
+
+ .globl __memcmp_aarch64_sve
+ .type __memcmp_aarch64_sve, %function
+ .p2align 4
+__memcmp_aarch64_sve:
+ mov x3, 0 /* initialize off */
+
+0: whilelo p0.b, x3, x2 /* while off < max */
+ b.none 9f
+
+ ld1b z0.b, p0/z, [x0, x3] /* read vectors bounded by max. */
+ ld1b z1.b, p0/z, [x1, x3]
+
+ /* Increment for a whole vector, even if we've only read a partial.
+ This is significantly cheaper than INCP, and since OFF is not
+ used after the loop it is ok to increment OFF past MAX. */
+ incb x3
+
+ cmpne p1.b, p0/z, z0.b, z1.b /* while no inequalities */
+ b.none 0b
+
+ /* Found inequality. */
+1: brkb p1.b, p0/z, p1.b /* find first such */
+ lasta w0, p1, z0.b /* extract each byte */
+ lasta w1, p1, z1.b
+ sub x0, x0, x1 /* return comparison */
+ ret
+
+ /* Found end-of-count. */
+9: mov x0, 0 /* return equality */
+ ret
+
+ .size __memcmp_aarch64_sve, . - __memcmp_aarch64_sve