[PATCH 1/2] raid6: neon: process four data disks per Horner step

Eric Biggers ebiggers at kernel.org
Thu Nov 19 14:44:18 PST 2026


On Wed, Nov 18, 2026 at 07:33:37PM +0100, Ard Biesheuvel wrote:
> diff --git a/lib/raid/raid6/arm/neon.uc b/lib/raid/raid6/arm/neon.uc
> index 14a9fc2c60fa..6f74e2b82fc4 100644
> --- a/lib/raid/raid6/arm/neon.uc
> +++ b/lib/raid/raid6/arm/neon.uc
> @@ -22,15 +22,29 @@
>   * $#-way unrolled NEON intrinsics math RAID-6 instruction set
>   *
>   * This file is postprocessed using unroll.awk
> + *
> + * The Q syndrome is evaluated using Horner's rule, but four data disks at a
> + * time, i.e.,
> + *
> + *   Q' = x^4 * Q + x^3 * D[z+3] + x^2 * D[z+2] + x * D[z+1] + D[z]

In gen_syndrome_real() and xor_syndrome_real() later in the file, z is
the highest disk index in each 4-disk step rather than the lowest.  So
it might make more sense to write this as:

      Q' = x^4 * Q + x^3 * D[z] + x^2 * D[z-1] + x * D[z-2] + D[z-3]

> +/* Q * x^4 + D3 * x^3 + D2 * x^2 + D1 * x + D0 */
> +static inline unative_t HORNER4(unative_t q, unative_t d3, unative_t d2,
> +				unative_t d1, unative_t d0, unative_t x1d)
> +{
> +	unative_t lo = vshlq_n_u8(q, 4) ^ vshlq_n_u8(d3, 3) ^
> +		       vshlq_n_u8(d2, 2) ^ vshlq_n_u8(d1, 1) ^ d0;
> +	unative_t hi = vshrq_n_u8(q, 4) ^ vshrq_n_u8(d3, 5) ^
> +		       vshrq_n_u8(d2, 6) ^ vshrq_n_u8(d1, 7);
> +
> +	return lo ^ PMUL(hi, x1d);
> +}

This is called right after 'q' is updated, so it will take a bit longer
to be available than the other inputs, and ideally the generated code
would XOR together the other inputs first.  Putting 'q' last might make
it more likely for the compiler to do that:

    unative_t lo = vshlq_n_u8(d3, 3) ^ vshlq_n_u8(d2, 2) ^
                   vshlq_n_u8(d1, 1) ^ d0 ^ vshlq_n_u8(q, 4);
    unative_t hi = vshrq_n_u8(d3, 5) ^ vshrq_n_u8(d2, 6) ^
                   vshrq_n_u8(d1, 7) ^ vshrq_n_u8(q, 4);

- Eric



More information about the linux-arm-kernel mailing list