[libc] [llvm] Add vector-based strlen implementation for x86_64 and aarch64 (PR #152389)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 7 13:16:36 PDT 2025


================
@@ -0,0 +1,50 @@
+//===-- Strlen implementation for aarch64 ---------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_STRLEN_H
+#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_STRLEN_H
+
+#include <arm_neon.h>
+#include <stddef.h> // size_t
+
+namespace LIBC_NAMESPACE_DECL {
+
+size_t string_length_neon(const char *src) {
+  using Vector __attribute__((may_alias)) = uint8x8_t;
+  uintptr_t misalign_bytes = reinterpret_case<uintptr_t>(src) % sizeof(Vector);
----------------
overmighty wrote:

> `reinterpret_case`

Typo? Also appears on lines 36 and 37: https://github.com/llvm/llvm-project/blob/fd74316cb584606acf3ebafcec094038d09ef79b/libc/src/string/memory_utils/aarch64/inline_strlen.h#L36-L37

https://github.com/llvm/llvm-project/pull/152389


More information about the llvm-commits mailing list