]> git.ipfire.org Git - thirdparty/coreutils.git/commit
wc: add aarch64 Neon optimization for wc -l
authorCollin Funk <collin.funk1@gmail.com>
Wed, 18 Feb 2026 08:03:05 +0000 (00:03 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Thu, 19 Feb 2026 04:09:44 +0000 (20:09 -0800)
commit6a3dde5dd2d77fa1aa5fac65d8f71bdad81471a1
tree37167d392a71a94743a0bfcacd9e534dc1657354
parent5f3a601fbb199a0ba087583394708c1e57ec13d6
wc: add aarch64 Neon optimization for wc -l

Here is an example of the performance improvement:

    $ yes abcdefghijklmnopqrstuvwxyz | head -n 100000000 > input
    $ time ./src/wc-prev -l < input
    100000000

    real 0m0.793s
    user 0m0.630s
    sys 0m0.162s
    $ time ./src/wc -l < input
    100000000

    real 0m0.230s
    user 0m0.065s
    sys 0m0.164s

* NEWS: Mention the performance improvement.
* gnulib: Update to the latest commit.
* configure.ac: Check the the necessary intrinsics and functions.
* src/local.mk (noinst_LIBRARIES) [USE_NEON_WC_LINECOUNT]: Add
src/libwc_neon.a.
(src_libwc_neon_a_SOURCES, wc_neon_ldadd, src_libwc_neon_a_CFLAGS)
[USE_NEON_WC_LINECOUNT]: New variables.
(src_wc_LDADD) [USE_NEON_WC_LINECOUNT]: Add $(wc_neon_ldadd).
* src/wc.c [USE_NEON_WC_LINECOUNT]: Include sys/auxv.h and asm/hwcap.h.
(neon_supported) [USE_NEON_WC_LINECOUNT]: New function.
(wc_lines) [USE_NEON_WC_LINECOUNT]: Use neon_supported and
wc_lines_neon.
* src/wc.h (wc_lines_neon): Add declaration.
* src/wc_neon.c: New file.
* doc/coreutils.texi (Hardware Acceleration): Document the "-ASIMD"
hwcap and the variable used in ./configure to override detection of Neon
instructions.
* tests/wc/wc-cpu.sh: Also add "-ASIMD" to disable the use of Neon
instructions.
NEWS
configure.ac
doc/coreutils.texi
gnulib
src/local.mk
src/wc.c
src/wc.h
src/wc_neon.c [new file with mode: 0644]
tests/wc/wc-cpu.sh