[x265] [PATCH v2 6/9] AArch64: Move Neon-SVE bridge helpers into dedicated header

Jonathan Wright jonathan.wright at arm.com
Tue Aug 27 15:11:06 UTC 2024


Move the inline helper functions that use the Neon-SVE bridge
intrinsics into their own dedicated header file (so that the helpers
can be re-used by other code in subsequent patches.)
---
 source/common/aarch64/neon-sve-bridge.h | 62 +++++++++++++++++++++++++
 source/common/aarch64/sao-prim.h        | 32 +------------
 2 files changed, 63 insertions(+), 31 deletions(-)
 create mode 100644 source/common/aarch64/neon-sve-bridge.h

diff --git a/source/common/aarch64/neon-sve-bridge.h b/source/common/aarch64/neon-sve-bridge.h
new file mode 100644
index 000000000..59ca8aab7
--- /dev/null
+++ b/source/common/aarch64/neon-sve-bridge.h
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * Copyright (C) 2024 MulticoreWare, Inc
+ *
+ * Authors: Hari Limaye <hari.limaye at arm.com>
+ *          Jonathan Wright <jonathan.wright at arm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at license @ x265.com.
+ *****************************************************************************/
+
+#ifndef X265_COMMON_AARCH64_NEON_SVE_BRIDGE_H
+#define X265_COMMON_AARCH64_NEON_SVE_BRIDGE_H
+
+#include <arm_neon.h>
+
+#if defined(HAVE_SVE) && HAVE_SVE_BRIDGE
+#include <arm_sve.h>
+#include <arm_neon_sve_bridge.h>
+
+/* We can access instructions that are exclusive to the SVE or SVE2 instruction
+ * sets from a predominantly Neon context by making use of the Neon-SVE bridge
+ * intrinsics to reinterpret Neon vectors as SVE vectors - with the high part of
+ * the SVE vector (if it's longer than 128 bits) being "don't care".
+ *
+ * While sub-optimal on machines that have SVE vector length > 128-bit - as the
+ * remainder of the vector is unused - this approach is still beneficial when
+ * compared to a Neon-only implementation. */
+
+static inline int64x2_t x265_sdotq_s16(int64x2_t acc, int16x8_t x, int16x8_t y)
+{
+    return svget_neonq_s64(svdot_s64(svset_neonq_s64(svundef_s64(), acc),
+                                     svset_neonq_s16(svundef_s16(), x),
+                                     svset_neonq_s16(svundef_s16(), y)));
+}
+
+static inline int8x16_t x265_sve_mask(const int x, const int endX,
+                                      const int8x16_t in)
+{
+    // Use predicate to shift "unused lanes" outside of range [-2, 2]
+    svbool_t svpred = svwhilelt_b8(x, endX);
+    svint8_t edge_type = svsel_s8(svpred, svset_neonq_s8(svundef_s8(), in),
+                                  svdup_n_s8(-3));
+    return svget_neonq_s8(edge_type);
+}
+
+#endif // defined(HAVE_SVE) && HAVE_SVE_BRIDGE
+
+#endif // X265_COMMON_AARCH64_NEON_SVE_BRIDGE_H
diff --git a/source/common/aarch64/sao-prim.h b/source/common/aarch64/sao-prim.h
index ff2e0f2ce..8258bd477 100644
--- a/source/common/aarch64/sao-prim.h
+++ b/source/common/aarch64/sao-prim.h
@@ -24,40 +24,10 @@
 #ifndef X265_COMMON_AARCH64_SAO_PRIM_H
 #define X265_COMMON_AARCH64_SAO_PRIM_H
 
+#include "neon-sve-bridge.h"
 #include "primitives.h"
 #include <arm_neon.h>
 
-#if defined(HAVE_SVE) && HAVE_SVE_BRIDGE
-#include <arm_neon_sve_bridge.h>
-
-/* We can access instructions that are exclusive to the SVE or SVE2 instruction
- * sets from a predominantly Neon context by making use of the Neon-SVE bridge
- * intrinsics to reinterpret Neon vectors as SVE vectors - with the high part of
- * the SVE vector (if it's longer than 128 bits) being "don't care".
- *
- * While sub-optimal on machines that have SVE vector length > 128-bit - as the
- * remainder of the vector is unused - this approach is still beneficial when
- * compared to a Neon-only implementation. */
-
-static inline int8x16_t x265_sve_mask(const int x, const int endX,
-                                      const int8x16_t in)
-{
-    // Use predicate to shift "unused lanes" outside of range [-2, 2]
-    svbool_t svpred = svwhilelt_b8(x, endX);
-    svint8_t edge_type = svsel_s8(svpred, svset_neonq_s8(svundef_s8(), in),
-                                  svdup_n_s8(-3));
-    return svget_neonq_s8(edge_type);
-}
-
-static inline int64x2_t x265_sdotq_s16(int64x2_t acc, int16x8_t x, int16x8_t y)
-{
-    return svget_neonq_s64(svdot_s64(svset_neonq_s64(svundef_s64(), acc),
-                                     svset_neonq_s16(svundef_s16(), x),
-                                     svset_neonq_s16(svundef_s16(), y)));
-}
-
-#endif // defined(HAVE_SVE) && HAVE_SVE_BRIDGE
-
 static inline int8x16_t signOf_neon(const pixel *a, const pixel *b)
 {
 #if HIGH_BIT_DEPTH
-- 
2.42.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0006-AArch64-Move-Neon-SVE-bridge-helpers-into-dedicat.patch
Type: text/x-patch
Size: 5720 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240827/919190e9/attachment.bin>


More information about the x265-devel mailing list