• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2017 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef VPX_VPX_DSP_ARM_SUM_NEON_H_
12 #define VPX_VPX_DSP_ARM_SUM_NEON_H_
13 
14 #include <arm_neon.h>
15 
16 #include "./vpx_config.h"
17 #include "vpx/vpx_integer.h"
18 
horizontal_add_int16x8(const int16x8_t a)19 static INLINE int32_t horizontal_add_int16x8(const int16x8_t a) {
20 #if defined(__aarch64__)
21   return vaddlvq_s16(a);
22 #else
23   const int32x4_t b = vpaddlq_s16(a);
24   const int64x2_t c = vpaddlq_s32(b);
25   const int32x2_t d = vadd_s32(vreinterpret_s32_s64(vget_low_s64(c)),
26                                vreinterpret_s32_s64(vget_high_s64(c)));
27   return vget_lane_s32(d, 0);
28 #endif
29 }
30 
horizontal_add_uint16x8(const uint16x8_t a)31 static INLINE uint32_t horizontal_add_uint16x8(const uint16x8_t a) {
32 #if defined(__aarch64__)
33   return vaddlvq_u16(a);
34 #else
35   const uint32x4_t b = vpaddlq_u16(a);
36   const uint64x2_t c = vpaddlq_u32(b);
37   const uint32x2_t d = vadd_u32(vreinterpret_u32_u64(vget_low_u64(c)),
38                                 vreinterpret_u32_u64(vget_high_u64(c)));
39   return vget_lane_u32(d, 0);
40 #endif
41 }
42 
horizontal_add_int32x2(const int32x2_t a)43 static INLINE int32_t horizontal_add_int32x2(const int32x2_t a) {
44 #if defined(__aarch64__)
45   return vaddv_s32(a);
46 #else
47   return vget_lane_s32(a, 0) + vget_lane_s32(a, 1);
48 #endif
49 }
50 
horizontal_add_uint32x2(const uint32x2_t a)51 static INLINE uint32_t horizontal_add_uint32x2(const uint32x2_t a) {
52 #if defined(__aarch64__)
53   return vaddv_u32(a);
54 #else
55   return vget_lane_u32(a, 0) + vget_lane_u32(a, 1);
56 #endif
57 }
58 
horizontal_add_int32x4(const int32x4_t a)59 static INLINE int32_t horizontal_add_int32x4(const int32x4_t a) {
60 #if defined(__aarch64__)
61   return vaddvq_s32(a);
62 #else
63   const int64x2_t b = vpaddlq_s32(a);
64   const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)),
65                                vreinterpret_s32_s64(vget_high_s64(b)));
66   return vget_lane_s32(c, 0);
67 #endif
68 }
69 
horizontal_add_uint32x4(const uint32x4_t a)70 static INLINE uint32_t horizontal_add_uint32x4(const uint32x4_t a) {
71 #if defined(__aarch64__)
72   return vaddvq_u32(a);
73 #else
74   const uint64x2_t b = vpaddlq_u32(a);
75   const uint32x2_t c = vadd_u32(vreinterpret_u32_u64(vget_low_u64(b)),
76                                 vreinterpret_u32_u64(vget_high_u64(b)));
77   return vget_lane_u32(c, 0);
78 #endif
79 }
80 #endif  // VPX_VPX_DSP_ARM_SUM_NEON_H_
81