From 73f6e82b1a9cbf36fdd0163005e06112e090337e Mon Sep 17 00:00:00 2001 From: George Steed Date: Mon, 18 Mar 2024 10:12:16 +0000 Subject: [PATCH] [AArch64] Add missing clobber, fix zero-init for compare kernels The "memory" clobber needs to be present even if the asm does not store anything to memory, since otherwise the compiler would be allowed to reorder earlier stores to the pointers after they would be needed by the asm. Also fix up the zero-initialisation of accumulators in SumSquareError_NEON, since EOR'ing a register by itself is not a recognised zeroing idiom on most AArch64 micro-architectures. Bug: libyuv:976 Change-Id: I3175367abf6f59db8371b4478f1156950277d7c5 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5378705 Reviewed-by: Frank Barchard --- source/compare_neon64.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/compare_neon64.cc b/source/compare_neon64.cc index 70fb9b914..1bc8d18c9 100644 --- a/source/compare_neon64.cc +++ b/source/compare_neon64.cc @@ -47,7 +47,7 @@ uint32_t HammingDistance_NEON(const uint8_t* src_a, "fmov %w3, s4 \n" : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(diff) : - : "cc", "v0", "v1", "v2", "v3", "v4"); + : "memory", "cc", "v0", "v1", "v2", "v3", "v4"); return diff; } @@ -56,10 +56,10 @@ uint32_t SumSquareError_NEON(const uint8_t* src_a, int count) { uint32_t sse; asm volatile( - "eor v16.16b, v16.16b, v16.16b \n" - "eor v18.16b, v18.16b, v18.16b \n" - "eor v17.16b, v17.16b, v17.16b \n" - "eor v19.16b, v19.16b, v19.16b \n" + "movi v16.16b, #0 \n" + "movi v17.16b, #0 \n" + "movi v18.16b, #0 \n" + "movi v19.16b, #0 \n" "1: \n" "ld1 {v0.16b}, [%0], #16 \n" @@ -82,7 +82,7 @@ uint32_t SumSquareError_NEON(const uint8_t* src_a, "fmov %w3, s0 \n" : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse) : - : "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19"); + : "memory", "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19"); return sse; }