Re: [PATCH v2] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation

From: Shreesh Adiga

Date: Tue Nov 17 2026 - 02:07:50 EST


Hi Demian,

On Tue, Nov 17, 2026 at 6:15 AM Demian Shulhan <demyansh@xxxxxxxxx> wrote:

> Scalar vmull_p64() makes compilers materialize the constants via mov/movk + fmov
> (42/97 insns on Clang). SHA3_TARGET also makes codegen fragile: with
> -march=armv8.5-a+crypto, GCC stops inlining pmull64*(). On Neoverse-V2, EOR3
> contends with PMULL on pipe V0, whereas regular EOR runs on all SIMD pipes.
> Using inline-asm pmull/pmull2 and a clean 4x unroll in crc64_nvme_neon() without
> EOR3 should give better performance across all sizes and cleaner code.
>
> /* clang -O2 */
> 24: mov x10, #0x45a
> 28: movk x10, #0xace5, lsl #16
> 2c: movk x10, #0x2240, lsl #32
> 30: movk x10, #0x6224, lsl #48
> 34: dup v4.2d, x10
> 38: mov x10, #0xa84a
> 3c: movk x10, #0x1e18, lsl #16
> 40: movk x10, #0xcdb3, lsl #32
> 44: movk x10, #0xc32, lsl #48
> 48: fmov d5, x10

Can I assume we want to have the 16-byte constants loaded using LD1
and use inline assembly for PMULL/PMULL2 and have the codegen not
perform the mov+movk+fmov instantiation?
Will look into extending the existing PMULL routine with 4x unrolling
and adding the partial block handling as well similar to x86 version.
I'll assume that 128 byte threshold for invoking this SIMD routine
still holds though, even though this is probably core specific.

For EOR3 though I assume it is still useful for many cores like
Cortex-X925, Cortex-A720, Cortex-X4 that I checked has measurable
speedup at 512B/4KB.
Maybe we can have a CPU core check for special cases like Neoverse-N2
which at the crc64_mod_init_arch we can check and avoid enabling the
static_branch?
Kindly let me know if it is not worth having EOR3 for all cores. For
now I will try to submit the existing PMULL routine enhancement as per
your suggestion.

Thanks,
Shreesh