From 02eac8a741a3d6b9bfacbceb750c44fba7ed4662 Mon Sep 17 00:00:00 2001 From: James Zern Date: Sat, 3 Jul 2021 17:45:13 -0700 Subject: [PATCH] dsp/cost*: use WEBP_RESTRICT qualifier on SetResidualCoeffs_*. This results in some minor code reordering when targeting arvm7 with ndk r27 and other recent versions of clang. No changes in the x86 compilations with clang-16 / gcc-13. This only affects non-vector pointers; any vector pointers are left as a follow up. Change-Id: I7c3554ece848fafbc5ac9c4944f1dc85129f6fd8 --- src/dsp/cost.c | 4 ++-- src/dsp/cost_mips32.c | 4 ++-- src/dsp/cost_neon.c | 4 ++-- src/dsp/cost_sse2.c | 4 ++-- src/dsp/dsp.h | 5 +++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/dsp/cost.c b/src/dsp/cost.c index 73d21401..609f9264 100644 --- a/src/dsp/cost.c +++ b/src/dsp/cost.c @@ -354,8 +354,8 @@ static int GetResidualCost_C(int ctx0, const VP8Residual* const res) { return cost; } -static void SetResidualCoeffs_C(const int16_t* const coeffs, - VP8Residual* const res) { +static void SetResidualCoeffs_C(const int16_t* WEBP_RESTRICT const coeffs, + VP8Residual* WEBP_RESTRICT const res) { int n; res->last = -1; assert(res->first == 0 || coeffs[0] == 0); diff --git a/src/dsp/cost_mips32.c b/src/dsp/cost_mips32.c index 0500f88c..54586576 100644 --- a/src/dsp/cost_mips32.c +++ b/src/dsp/cost_mips32.c @@ -96,8 +96,8 @@ static int GetResidualCost_MIPS32(int ctx0, const VP8Residual* const res) { return cost; } -static void SetResidualCoeffs_MIPS32(const int16_t* const coeffs, - VP8Residual* const res) { +static void SetResidualCoeffs_MIPS32(const int16_t* WEBP_RESTRICT const coeffs, + VP8Residual* WEBP_RESTRICT const res) { const int16_t* p_coeffs = (int16_t*)coeffs; int temp0, temp1, temp2, n, n1; assert(res->first == 0 || coeffs[0] == 0); diff --git a/src/dsp/cost_neon.c b/src/dsp/cost_neon.c index 6582669c..e1bf3657 100644 --- a/src/dsp/cost_neon.c +++ b/src/dsp/cost_neon.c @@ -19,8 +19,8 @@ static const uint8_t position[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; -static void SetResidualCoeffs_NEON(const int16_t* const coeffs, - VP8Residual* const res) { +static void SetResidualCoeffs_NEON(const int16_t* WEBP_RESTRICT const coeffs, + VP8Residual* WEBP_RESTRICT const res) { const int16x8_t minus_one = vdupq_n_s16(-1); const int16x8_t coeffs_0 = vld1q_s16(coeffs); const int16x8_t coeffs_1 = vld1q_s16(coeffs + 8); diff --git a/src/dsp/cost_sse2.c b/src/dsp/cost_sse2.c index 487a0799..a869b48d 100644 --- a/src/dsp/cost_sse2.c +++ b/src/dsp/cost_sse2.c @@ -22,8 +22,8 @@ //------------------------------------------------------------------------------ -static void SetResidualCoeffs_SSE2(const int16_t* const coeffs, - VP8Residual* const res) { +static void SetResidualCoeffs_SSE2(const int16_t* WEBP_RESTRICT const coeffs, + VP8Residual* WEBP_RESTRICT const res) { const __m128i c0 = _mm_loadu_si128((const __m128i*)(coeffs + 0)); const __m128i c1 = _mm_loadu_si128((const __m128i*)(coeffs + 8)); // Use SSE2 to compare 16 values with a single instruction. diff --git a/src/dsp/dsp.h b/src/dsp/dsp.h index 23bc2965..82029533 100644 --- a/src/dsp/dsp.h +++ b/src/dsp/dsp.h @@ -138,8 +138,9 @@ extern const uint16_t VP8LevelFixedCosts[2047 /*MAX_LEVEL*/ + 1]; extern const uint8_t VP8EncBands[16 + 1]; struct VP8Residual; -typedef void (*VP8SetResidualCoeffsFunc)(const int16_t* const coeffs, - struct VP8Residual* const res); +typedef void (*VP8SetResidualCoeffsFunc)( + const int16_t* WEBP_RESTRICT const coeffs, + struct VP8Residual* WEBP_RESTRICT const res); extern VP8SetResidualCoeffsFunc VP8SetResidualCoeffs; // Cost calculation function.