You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the algorithms in crc32_arm64.c to work consistenly, all multibyte
integers loaded from the input buffer have to be loaded in little-endian.
Tested on an aarch64_be-unknown-linux-musl system, with:
ninja crc32-t && unittest/mysys/crc32-t
Test results:
unpatched:
+------------------------------------+-------------------+--------------------+
| Code path | GCC 15.2.0 | Clang 20.1.8 |
+------------------------------------+-------------------+--------------------+
|`crc32c_aarch64` | 25 failed tests | 25 failed tests |
+------------------------------------+-------------------+--------------------+
|`crc32c_aarch64_pmull` (assembly) | 25 failed tests | doesn't compile |
+------------------------------------+-------------------+--------------------+
|`crc32c_aarch64_pmull` (intrinsics) | 25 failed tests | 26 failed tests |
+------------------------------------+-------------------+--------------------+
patched:
+------------------------------------+-------------------+--------------------+
| Code path | GCC 15.2.0 | Clang 20.1.8 |
+------------------------------------+-------------------+--------------------+
|`crc32c_aarch64` | success | success |
+------------------------------------+-------------------+--------------------+
|`crc32c_aarch64_pmull` (assembly) | success | doesn't compile |
+------------------------------------+-------------------+--------------------+
|`crc32c_aarch64_pmull` (intrinsics) | success | 1 failed test |
+------------------------------------+-------------------+--------------------+
Implementation notes:
- uintNkorr uses the byte-wise implementation of a fixed-endian load,
which can't always be turned back into a single load instruction.
On aarch64-unknown-linux-musl (little endian) with GCC 15.2, this
resulted in a code pessimization at -O0 and -O1, but -Os and -O2 are
fine, so this is not a problem.
On MSVC/Windows there does appear to be a pessimization[1].
- Using le16toh etc. are a potential alternative, as these macros are
no-ops on little-endian platforms that support them. The endian(3)
manpage suggests that NetBSD, FreeBSD, and glibc (in addition to
musl), but not OpenBSD, support them[2]. Windows support is unclear.
leNNtoh has the added disadvantage of being unusual in the MariaDB
codebase, so it's better to stick with uintNkorr.
[1]: https://godbolt.org/z/oncv9Gj19
[2]: https://man.he.net/man3/htole64
0 commit comments