Debian Codegraph @

third-party/simde/x86/avx512/sllv.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 Hidayat Khan <[email protected]>
26 */
27
28 #if !defined(SIMDE_X86_AVX512_SLLV_H)
29 #define SIMDE_X86_AVX512_SLLV_H
30
31 #include "types.h"
32 #include "mov.h"
33
34 HEDLEY_DIAGNOSTIC_PUSH
35 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
36 SIMDE_BEGIN_DECLS_
37
38 SIMDE_FUNCTION_ATTRIBUTES
39 simde__m512i
40 simde_mm512_sllv_epi16 (simde__m512i a, simde__m512i b) {
41 simde__m512i_private
42 a_ = simde__m512i_to_private(a),
43 b_ = simde__m512i_to_private(b),
44 r_;
45
46 #if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR)
47 r_.u16 = HEDLEY_REINTERPRET_CAST(__typeof__(r_.u16), (b_.u16 < 16)) & (a_.u16 << b_.u16);
48 #else
49 SIMDE_VECTORIZE
50 for (size_t i = 0 ; i < (sizeof(r_.u16) / sizeof(r_.u16[0])) ; i++) {
51 r_.u16[i] = (b_.u16[i] < 16) ? HEDLEY_STATIC_CAST(uint16_t, (a_.u16[i] << b_.u16[i])) : 0;
52 }
53 #endif
54
55 return simde__m512i_from_private(r_);
56 }
57 #if defined(SIMDE_X86_AVX512BW_NATIVE)
58 #define simde_mm512_sllv_epi16(a, b) _mm512_sllv_epi16(a, b)
59 #endif
60 #if defined(SIMDE_X86_AVX512BW_ENABLE_NATIVE_ALIASES)
61 #undef _mm512_sllv_epi16
62 #define _mm512_sllv_epi16(a, b) simde_mm512_sllv_epi16(a, b)
63 #endif
64
65 SIMDE_FUNCTION_ATTRIBUTES
66 simde__m512i
67 simde_mm512_sllv_epi32 (simde__m512i a, simde__m512i b) {
68 simde__m512i_private
69 a_ = simde__m512i_to_private(a),
70 b_ = simde__m512i_to_private(b),
71 r_;
72
73 #if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR)
74 r_.u32 = HEDLEY_REINTERPRET_CAST(__typeof__(r_.u32), (b_.u32 < 32)) & (a_.u32 << b_.u32);
75 #else
76 SIMDE_VECTORIZE
77 for (size_t i = 0 ; i < (sizeof(r_.u32) / sizeof(r_.u32[0])) ; i++) {
78 r_.u32[i] = (b_.u32[i] < 32) ? HEDLEY_STATIC_CAST(uint32_t, (a_.u32[i] << b_.u32[i])) : 0;
79 }
80 #endif
81
82 return simde__m512i_from_private(r_);
83 }
84 #if defined(SIMDE_X86_AVX512F_NATIVE)
85 #define simde_mm512_sllv_epi32(a, b) _mm512_sllv_epi32(a, b)
86 #endif
87 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
88 #undef _mm512_sllv_epi32
89 #define _mm512_sllv_epi32(a, b) simde_mm512_sllv_epi32(a, b)
90 #endif
91
92 SIMDE_FUNCTION_ATTRIBUTES
93 simde__m512i
94 simde_mm512_sllv_epi64 (simde__m512i a, simde__m512i b) {
95 simde__m512i_private
96 a_ = simde__m512i_to_private(a),
97 b_ = simde__m512i_to_private(b),
98 r_;
99
100 #if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR)
101 r_.u64 = HEDLEY_REINTERPRET_CAST(__typeof__(r_.u64), (b_.u64 < 64)) & (a_.u64 << b_.u64);
102 #else
103 SIMDE_VECTORIZE
104 for (size_t i = 0 ; i < (sizeof(r_.u64) / sizeof(r_.u64[0])) ; i++) {
105 r_.u64[i] = (b_.u64[i] < 64) ? HEDLEY_STATIC_CAST(uint64_t, (a_.u64[i] << b_.u64[i])) : 0;
106 }
107 #endif
108
109 return simde__m512i_from_private(r_);
110 }
111 #if defined(SIMDE_X86_AVX512F_NATIVE)
112 #define simde_mm512_sllv_epi64(a, b) _mm512_sllv_epi64(a, b)
113 #endif
114 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
115 #undef _mm512_sllv_epi64
116 #define _mm512_sllv_epi64(a, b) simde_mm512_sllv_epi64(a, b)
117 #endif
118
119 SIMDE_END_DECLS_
120 HEDLEY_DIAGNOSTIC_POP
121
122 #endif /* !defined(SIMDE_X86_AVX512_SLLV_H) */