Skip to content

Commit

Permalink
lib/raid6: use vdupq_n_u8 to avoid endianness warnings
Browse files Browse the repository at this point in the history
Clang warns: vector initializers are not compatible with NEON intrinsics
in big endian mode [-Wnonportable-vector-initialization]

While this is usually the case, it's not an issue for this case since
we're initializing the uint8x16_t (16x uint8_t's) with the same value.

Instead, use vdupq_n_u8 which both compilers lower into a single movi
instruction: https://godbolt.org/z/vBrgzt

This avoids the static storage for a constant value.

Link: ClangBuiltLinux/linux#214
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
  • Loading branch information
nickdesaulniers authored and ctmarinas committed Feb 28, 2019
1 parent 2c97a9c commit 1ad3935
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 2 additions & 3 deletions lib/raid6/neon.uc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

typedef uint8x16_t unative_t;

#define NBYTES(x) ((unative_t){x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x})
#define NSIZE sizeof(unative_t)

/*
Expand Down Expand Up @@ -61,7 +60,7 @@ void raid6_neon$#_gen_syndrome_real(int disks, unsigned long bytes, void **ptrs)
int d, z, z0;

register unative_t wd$$, wq$$, wp$$, w1$$, w2$$;
const unative_t x1d = NBYTES(0x1d);
const unative_t x1d = vdupq_n_u8(0x1d);

z0 = disks - 3; /* Highest data disk */
p = dptr[z0+1]; /* XOR parity */
Expand Down Expand Up @@ -92,7 +91,7 @@ void raid6_neon$#_xor_syndrome_real(int disks, int start, int stop,
int d, z, z0;

register unative_t wd$$, wq$$, wp$$, w1$$, w2$$;
const unative_t x1d = NBYTES(0x1d);
const unative_t x1d = vdupq_n_u8(0x1d);

z0 = stop; /* P/Q right side optimization */
p = dptr[disks-2]; /* XOR parity */
Expand Down
7 changes: 2 additions & 5 deletions lib/raid6/recov_neon_inner.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@

#include <arm_neon.h>

static const uint8x16_t x0f = {
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
};

#ifdef CONFIG_ARM
/*
* AArch32 does not provide this intrinsic natively because it does not
Expand All @@ -41,6 +36,7 @@ void __raid6_2data_recov_neon(int bytes, uint8_t *p, uint8_t *q, uint8_t *dp,
uint8x16_t pm1 = vld1q_u8(pbmul + 16);
uint8x16_t qm0 = vld1q_u8(qmul);
uint8x16_t qm1 = vld1q_u8(qmul + 16);
uint8x16_t x0f = vdupq_n_u8(0x0f);

/*
* while ( bytes-- ) {
Expand Down Expand Up @@ -87,6 +83,7 @@ void __raid6_datap_recov_neon(int bytes, uint8_t *p, uint8_t *q, uint8_t *dq,
{
uint8x16_t qm0 = vld1q_u8(qmul);
uint8x16_t qm1 = vld1q_u8(qmul + 16);
uint8x16_t x0f = vdupq_n_u8(0x0f);

/*
* while (bytes--) {
Expand Down

0 comments on commit 1ad3935

Please sign in to comment.