casaroli commented on code in PR #22184:
URL: https://github.com/apache/nuttx/pull/22184#discussion_r4665501180
##########
libs/libc/machine/arm64/Kconfig:
##########
@@ -28,27 +28,28 @@ config ARM64_STRING_FUNCTION
bool "Enable optimized ARM64 specific string function"
default n
depends on ARCH_TOOLCHAIN_GNU
- select ARM64_MEMCHR
+ select ARM64_MEMCHR if ARCH_FPU
select ARM64_MEMCMP
- select ARM64_MEMCPY
- select ARM64_MEMSET
+ select ARM64_MEMCPY if ARCH_FPU
+ select ARM64_MEMSET if ARCH_FPU
select ARM64_MEMMOVE
Review Comment:
With `ARCH_FPU=n`, `ARM64_STRING_FUNCTION` still selects `ARM64_MEMMOVE` but
no longer `ARM64_MEMCPY`. `arch_memmove.S` (lines 97-109) sends every memmove
of up to 96 bytes to `memcpy` because it supports overlaps; without
`ARM64_MEMCPY` that is the byte loop of `lib_memcpy.c`, so `memmove(p + 1, p,
2)` gives a wrong result.
Fix: `select ARM64_MEMMOVE if ARCH_FPU`, and add `depends on ARM64_MEMCPY`
to `ARM64_MEMMOVE`.
##########
libs/libc/machine/arm64/arch_memcpy.S:
##########
@@ -102,137 +102,127 @@
\f:
.endm
-/* Copies are split into 3 main cases: small copies of up to 16 bytes,
- medium copies of 17..96 bytes which are fully unrolled. Large copies
- of more than 96 bytes align the destination and use an unrolled loop
- processing 64 bytes per iteration.
- Small and medium copies read all data before writing, allowing any
- kind of overlap, and memmove tailcalls memcpy for these cases as
- well as non-overlapping copies.
-*/
+/* Advanced SIMD memcpy. memcpy assumes the source and destination regions
Review Comment:
`arch_memmove.S` calls this memcpy for overlapping moves (all moves up to 96
bytes, and dst < src), so memcpy must keep supporting them. The new comment
says the opposite.
Fix: say that copies up to 128 bytes read all data before they write, and
that the forward loop is safe for dst < src, because memmove relies on it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]