Debian Codegraph @

third-party/simde/arm/neon/rndi.h

raw
1 /* SPDX-License-Identifier: MIT
2 *
3 * Permission is hereby granted, free of charge, to any person
4 * obtaining a copy of this software and associated documentation
5 * files (the "Software"), to deal in the Software without
6 * restriction, including without limitation the rights to use, copy,
7 * modify, merge, publish, distribute, sublicense, and/or sell copies
8 * of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be
12 * included in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Copyright:
24 * 2020-2021 Evan Nemerson <[email protected]>
25 */
26
27 #if !defined(SIMDE_ARM_NEON_RNDI_H)
28 #define SIMDE_ARM_NEON_RNDI_H
29
30 #include "types.h"
31
32 HEDLEY_DIAGNOSTIC_PUSH
33 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
34 SIMDE_BEGIN_DECLS_
35
36 SIMDE_FUNCTION_ATTRIBUTES
37 simde_float32x2_t
38 simde_vrndi_f32(simde_float32x2_t a) {
39 #if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && !defined(SIMDE_BUG_GCC_95399)
40 return vrndi_f32(a);
41 #else
42 simde_float32x2_private
43 r_,
44 a_ = simde_float32x2_to_private(a);
45
46 SIMDE_VECTORIZE
47 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
48 r_.values[i] = simde_math_nearbyintf(a_.values[i]);
49 }
50
51 return simde_float32x2_from_private(r_);
52 #endif
53 }
54 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
55 #undef vrndi_f32
56 #define vrndi_f32(a) simde_vrndi_f32(a)
57 #endif
58
59 SIMDE_FUNCTION_ATTRIBUTES
60 simde_float64x1_t
61 simde_vrndi_f64(simde_float64x1_t a) {
62 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && !defined(SIMDE_BUG_GCC_95399)
63 return vrndi_f64(a);
64 #else
65 simde_float64x1_private
66 r_,
67 a_ = simde_float64x1_to_private(a);
68
69 SIMDE_VECTORIZE
70 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
71 r_.values[i] = simde_math_nearbyint(a_.values[i]);
72 }
73
74 return simde_float64x1_from_private(r_);
75 #endif
76 }
77 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
78 #undef vrndi_f64
79 #define vrndi_f64(a) simde_vrndi_f64(a)
80 #endif
81
82 SIMDE_FUNCTION_ATTRIBUTES
83 simde_float32x4_t
84 simde_vrndiq_f32(simde_float32x4_t a) {
85 #if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && !defined(SIMDE_BUG_GCC_95399)
86 return vrndiq_f32(a);
87 #else
88 simde_float32x4_private
89 r_,
90 a_ = simde_float32x4_to_private(a);
91
92 #if defined(SIMDE_X86_SSE4_1_NATIVE)
93 r_.m128 = _mm_round_ps(a_.m128, _MM_FROUND_CUR_DIRECTION);
94 #else
95 SIMDE_VECTORIZE
96 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
97 r_.values[i] = simde_math_nearbyintf(a_.values[i]);
98 }
99 #endif
100
101 return simde_float32x4_from_private(r_);
102 #endif
103 }
104 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
105 #undef vrndiq_f32
106 #define vrndiq_f32(a) simde_vrndiq_f32(a)
107 #endif
108
109 SIMDE_FUNCTION_ATTRIBUTES
110 simde_float64x2_t
111 simde_vrndiq_f64(simde_float64x2_t a) {
112 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && !defined(SIMDE_BUG_GCC_95399)
113 return vrndiq_f64(a);
114 #else
115 simde_float64x2_private
116 r_,
117 a_ = simde_float64x2_to_private(a);
118
119 #if defined(SIMDE_X86_SSE4_1_NATIVE)
120 r_.m128d = _mm_round_pd(a_.m128d, _MM_FROUND_CUR_DIRECTION);
121 #else
122 SIMDE_VECTORIZE
123 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
124 r_.values[i] = simde_math_nearbyint(a_.values[i]);
125 }
126 #endif
127
128 return simde_float64x2_from_private(r_);
129 #endif
130 }
131 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
132 #undef vrndiq_f64
133 #define vrndiq_f64(a) simde_vrndiq_f64(a)
134 #endif
135
136 SIMDE_END_DECLS_
137 HEDLEY_DIAGNOSTIC_POP
138
139 #endif /* !defined(SIMDE_ARM_NEON_RNDI_H) */