Debian Codegraph @

third-party/simde/x86/avx512/expand.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 * 2021 Andrew Rodriguez <[email protected]>
25 * 2021 Evan Nemerson <[email protected]>
26 */
27
28 #if !defined(SIMDE_X86_AVX512_EXPAND_H)
29 #define SIMDE_X86_AVX512_EXPAND_H
30
31 #include "types.h"
32 #include "mov.h"
33 #include "mov_mask.h"
34
35 HEDLEY_DIAGNOSTIC_PUSH
36 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
37 SIMDE_BEGIN_DECLS_
38
39 SIMDE_FUNCTION_ATTRIBUTES
40 simde__m256i
41 simde_mm256_mask_expand_epi32(simde__m256i src, simde__mmask8 k, simde__m256i a) {
42 #if defined(SIMDE_X86_AVX512VL_NATIVE)
43 return _mm256_mask_expand_epi32(src, k, a);
44 #else
45 simde__m256i_private
46 a_ = simde__m256i_to_private(a),
47 src_ = simde__m256i_to_private(src);
48 simde__m256i_private r_;
49
50 size_t src_idx = 0;
51 for (size_t i = 0; i < (sizeof(r_.i32) / sizeof(r_.i32[0])) ; i++) {
52 if (k & (UINT64_C(1) << i)) {
53 r_.i32[i] = a_.i32[src_idx++];
54 } else {
55 r_.i32[i] = src_.i32[i];
56 }
57 }
58
59 return simde__m256i_from_private(r_);
60 #endif
61 }
62 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
63 #undef _mm256_mask_expand_epi32
64 #define _mm256_mask_expand_epi32(src, k, a) simde_mm256_mask_expand_epi32((src), (k), (a))
65 #endif
66
67 SIMDE_FUNCTION_ATTRIBUTES
68 simde__m256i
69 simde_mm256_maskz_expand_epi32(simde__mmask8 k, simde__m256i a) {
70 #if defined(SIMDE_X86_AVX512VL_NATIVE)
71 return _mm256_maskz_expand_epi32(k, a);
72 #else
73 simde__m256i_private
74 a_ = simde__m256i_to_private(a),
75 r_;
76
77 size_t src_idx = 0;
78 for (size_t i = 0; i < (sizeof(r_.i32) / sizeof(r_.i32[0])) ; i++) {
79 if (k & (UINT64_C(1) << i)) {
80 r_.i32[i] = a_.i32[src_idx++];
81 } else {
82 r_.i32[i] = INT32_C(0);
83 }
84 }
85
86 return simde__m256i_from_private(r_);
87 #endif
88 }
89 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
90 #undef _mm256_maskz_expand_epi32
91 #define _mm256_maskz_expand_epi32(k, a) simde_mm256_maskz_expand_epi32((k), (a))
92 #endif
93
94 SIMDE_END_DECLS_
95 HEDLEY_DIAGNOSTIC_POP
96
97 #endif /* !defined(SIMDE_X86_AVX512_EXPAND_H) */