Debian Codegraph @

third-party/simde/x86/avx512/negate.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 Evan Nemerson <[email protected]>
25 * 2020 Himanshi Mathur <[email protected]>
26 */
27
28 #if !defined(SIMDE_X86_AVX512_NEGATE_H)
29 #define SIMDE_X86_AVX512_NEGATE_H
30
31 #include "types.h"
32 #include "mov.h"
33 #include "xor.h"
34
35 HEDLEY_DIAGNOSTIC_PUSH
36 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
37 SIMDE_BEGIN_DECLS_
38
39 SIMDE_FUNCTION_ATTRIBUTES
40 simde__m512
41 simde_x_mm512_negate_ps(simde__m512 a) {
42 #if defined(SIMDE_X86_AVX512DQ_NATIVE)
43 return simde_mm512_xor_ps(a,_mm512_set1_ps(SIMDE_FLOAT32_C(-0.0)));
44 #else
45 simde__m512_private
46 r_,
47 a_ = simde__m512_to_private(a);
48
49 #if defined(SIMDE_VECTOR_NEGATE)
50 r_.f32 = -a_.f32;
51 #else
52 SIMDE_VECTORIZE
53 for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) {
54 r_.f32[i] = -a_.f32[i];
55 }
56 #endif
57
58 return simde__m512_from_private(r_);
59 #endif
60 }
61
62 SIMDE_FUNCTION_ATTRIBUTES
63 simde__m512d
64 simde_x_mm512_negate_pd(simde__m512d a) {
65 #if defined(SIMDE_X86_AVX512DQ_NATIVE)
66 return simde_mm512_xor_pd(a, _mm512_set1_pd(SIMDE_FLOAT64_C(-0.0)));
67 #else
68 simde__m512d_private
69 r_,
70 a_ = simde__m512d_to_private(a);
71
72 #if defined(SIMDE_VECTOR_NEGATE)
73 r_.f64 = -a_.f64;
74 #else
75 SIMDE_VECTORIZE
76 for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) {
77 r_.f64[i] = -a_.f64[i];
78 }
79 #endif
80
81 return simde__m512d_from_private(r_);
82 #endif
83 }
84
85 SIMDE_END_DECLS_
86 HEDLEY_DIAGNOSTIC_POP
87
88 #endif /* !defined(SIMDE_X86_AVX512_NEGATE_H) */