Debian Codegraph @

third-party/simde/x86/avx512/mulhi.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_MULHI_H)
29 #define SIMDE_X86_AVX512_MULHI_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_mulhi_epi16 (simde__m512i a, simde__m512i b) {
41 #if defined(SIMDE_X86_AVX512BW_NATIVE)
42 return _mm512_mulhi_epi16(a, b);
43 #else
44 simde__m512i_private
45 r_,
46 a_ = simde__m512i_to_private(a),
47 b_ = simde__m512i_to_private(b);
48
49 SIMDE_VECTORIZE
50 for (size_t i = 0 ; i < (sizeof(r_.i16) / sizeof(r_.i16[0])) ; i++) {
51 r_.u16[i] = HEDLEY_STATIC_CAST(uint16_t, (HEDLEY_STATIC_CAST(uint32_t, HEDLEY_STATIC_CAST(int32_t, a_.i16[i]) * HEDLEY_STATIC_CAST(int32_t, b_.i16[i])) >> 16));
52 }
53
54 return simde__m512i_from_private(r_);
55 #endif
56 }
57 #if defined(SIMDE_X86_AVX512BW_ENABLE_NATIVE_ALIASES)
58 #undef _mm512_mulhi_epi16
59 #define _mm512_mulhi_epi16(a, b) simde_mm512_mulhi_epi16(a, b)
60 #endif
61
62 SIMDE_END_DECLS_
63 HEDLEY_DIAGNOSTIC_POP
64
65 #endif /* !defined(SIMDE_X86_AVX512_MULHI_H) */