blob: afdea888c55ba05b24a9e39e7e03080ada026576 [file] [log] [blame]
Michael Zuckerman0190c652016-03-07 09:55:55 +00001/*===------------- avx512ifmavlintrin.h - IFMA intrinsics ------------------===
2 *
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies 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 included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 *
22 *===-----------------------------------------------------------------------===
23 */
24#ifndef __IMMINTRIN_H
25#error "Never use <avx512ifmavlintrin.h> directly; include <immintrin.h> instead."
26#endif
27
28#ifndef __IFMAVLINTRIN_H
29#define __IFMAVLINTRIN_H
30
31/* Define the default attributes for the functions in this file. */
Craig Topper74c10e32018-07-09 19:00:16 +000032#define __DEFAULT_FN_ATTRS128 __attribute__((__always_inline__, __nodebug__, __target__("avx512ifma,avx512vl"), __min_vector_width__(128)))
33#define __DEFAULT_FN_ATTRS256 __attribute__((__always_inline__, __nodebug__, __target__("avx512ifma,avx512vl"), __min_vector_width__(256)))
Michael Zuckerman0190c652016-03-07 09:55:55 +000034
35
36
Craig Topper74c10e32018-07-09 19:00:16 +000037static __inline__ __m128i __DEFAULT_FN_ATTRS128
Michael Zuckerman0190c652016-03-07 09:55:55 +000038_mm_madd52hi_epu64 (__m128i __X, __m128i __Y, __m128i __Z)
39{
Craig Topper387b1422018-05-26 18:55:26 +000040 return (__m128i)__builtin_ia32_vpmadd52huq128((__v2di) __X, (__v2di) __Y,
41 (__v2di) __Z);
Michael Zuckerman0190c652016-03-07 09:55:55 +000042}
43
Craig Topper74c10e32018-07-09 19:00:16 +000044static __inline__ __m128i __DEFAULT_FN_ATTRS128
Michael Zuckerman0190c652016-03-07 09:55:55 +000045_mm_mask_madd52hi_epu64 (__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y)
46{
Craig Topper387b1422018-05-26 18:55:26 +000047 return (__m128i)__builtin_ia32_selectq_128(__M,
48 (__v2di)_mm_madd52hi_epu64(__W, __X, __Y),
49 (__v2di)__W);
Michael Zuckerman0190c652016-03-07 09:55:55 +000050}
51
Craig Topper74c10e32018-07-09 19:00:16 +000052static __inline__ __m128i __DEFAULT_FN_ATTRS128
Michael Zuckerman0190c652016-03-07 09:55:55 +000053_mm_maskz_madd52hi_epu64 (__mmask8 __M, __m128i __X, __m128i __Y, __m128i __Z)
54{
Craig Topper387b1422018-05-26 18:55:26 +000055 return (__m128i)__builtin_ia32_selectq_128(__M,
56 (__v2di)_mm_madd52hi_epu64(__X, __Y, __Z),
57 (__v2di)_mm_setzero_si128());
Michael Zuckerman0190c652016-03-07 09:55:55 +000058}
59
Craig Topper74c10e32018-07-09 19:00:16 +000060static __inline__ __m256i __DEFAULT_FN_ATTRS256
Michael Zuckerman0190c652016-03-07 09:55:55 +000061_mm256_madd52hi_epu64 (__m256i __X, __m256i __Y, __m256i __Z)
62{
Craig Topper387b1422018-05-26 18:55:26 +000063 return (__m256i)__builtin_ia32_vpmadd52huq256((__v4di)__X, (__v4di)__Y,
64 (__v4di)__Z);
Michael Zuckerman0190c652016-03-07 09:55:55 +000065}
66
Craig Topper74c10e32018-07-09 19:00:16 +000067static __inline__ __m256i __DEFAULT_FN_ATTRS256
Craig Topper387b1422018-05-26 18:55:26 +000068_mm256_mask_madd52hi_epu64 (__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y)
Michael Zuckerman0190c652016-03-07 09:55:55 +000069{
Craig Topper387b1422018-05-26 18:55:26 +000070 return (__m256i)__builtin_ia32_selectq_256(__M,
71 (__v4di)_mm256_madd52hi_epu64(__W, __X, __Y),
72 (__v4di)__W);
Michael Zuckerman0190c652016-03-07 09:55:55 +000073}
74
Craig Topper74c10e32018-07-09 19:00:16 +000075static __inline__ __m256i __DEFAULT_FN_ATTRS256
Michael Zuckerman0190c652016-03-07 09:55:55 +000076_mm256_maskz_madd52hi_epu64 (__mmask8 __M, __m256i __X, __m256i __Y, __m256i __Z)
77{
Craig Topper387b1422018-05-26 18:55:26 +000078 return (__m256i)__builtin_ia32_selectq_256(__M,
79 (__v4di)_mm256_madd52hi_epu64(__X, __Y, __Z),
80 (__v4di)_mm256_setzero_si256());
Michael Zuckerman0190c652016-03-07 09:55:55 +000081}
82
Craig Topper74c10e32018-07-09 19:00:16 +000083static __inline__ __m128i __DEFAULT_FN_ATTRS128
Michael Zuckerman0190c652016-03-07 09:55:55 +000084_mm_madd52lo_epu64 (__m128i __X, __m128i __Y, __m128i __Z)
85{
Craig Topper387b1422018-05-26 18:55:26 +000086 return (__m128i)__builtin_ia32_vpmadd52luq128((__v2di)__X, (__v2di)__Y,
87 (__v2di)__Z);
Michael Zuckerman0190c652016-03-07 09:55:55 +000088}
89
Craig Topper74c10e32018-07-09 19:00:16 +000090static __inline__ __m128i __DEFAULT_FN_ATTRS128
Michael Zuckerman0190c652016-03-07 09:55:55 +000091_mm_mask_madd52lo_epu64 (__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y)
92{
Craig Topper387b1422018-05-26 18:55:26 +000093 return (__m128i)__builtin_ia32_selectq_128(__M,
94 (__v2di)_mm_madd52lo_epu64(__W, __X, __Y),
95 (__v2di)__W);
Michael Zuckerman0190c652016-03-07 09:55:55 +000096}
97
Craig Topper74c10e32018-07-09 19:00:16 +000098static __inline__ __m128i __DEFAULT_FN_ATTRS128
Michael Zuckerman0190c652016-03-07 09:55:55 +000099_mm_maskz_madd52lo_epu64 (__mmask8 __M, __m128i __X, __m128i __Y, __m128i __Z)
100{
Craig Topper387b1422018-05-26 18:55:26 +0000101 return (__m128i)__builtin_ia32_selectq_128(__M,
102 (__v2di)_mm_madd52lo_epu64(__X, __Y, __Z),
103 (__v2di)_mm_setzero_si128());
Michael Zuckerman0190c652016-03-07 09:55:55 +0000104}
105
Craig Topper74c10e32018-07-09 19:00:16 +0000106static __inline__ __m256i __DEFAULT_FN_ATTRS256
Michael Zuckerman0190c652016-03-07 09:55:55 +0000107_mm256_madd52lo_epu64 (__m256i __X, __m256i __Y, __m256i __Z)
108{
Craig Topper387b1422018-05-26 18:55:26 +0000109 return (__m256i)__builtin_ia32_vpmadd52luq256((__v4di)__X, (__v4di)__Y,
110 (__v4di)__Z);
Michael Zuckerman0190c652016-03-07 09:55:55 +0000111}
112
Craig Topper74c10e32018-07-09 19:00:16 +0000113static __inline__ __m256i __DEFAULT_FN_ATTRS256
Craig Topper387b1422018-05-26 18:55:26 +0000114_mm256_mask_madd52lo_epu64 (__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y)
Michael Zuckerman0190c652016-03-07 09:55:55 +0000115{
Craig Topper387b1422018-05-26 18:55:26 +0000116 return (__m256i)__builtin_ia32_selectq_256(__M,
117 (__v4di)_mm256_madd52lo_epu64(__W, __X, __Y),
118 (__v4di)__W);
Michael Zuckerman0190c652016-03-07 09:55:55 +0000119}
120
Craig Topper74c10e32018-07-09 19:00:16 +0000121static __inline__ __m256i __DEFAULT_FN_ATTRS256
Michael Zuckerman0190c652016-03-07 09:55:55 +0000122_mm256_maskz_madd52lo_epu64 (__mmask8 __M, __m256i __X, __m256i __Y, __m256i __Z)
123{
Craig Topper387b1422018-05-26 18:55:26 +0000124 return (__m256i)__builtin_ia32_selectq_256(__M,
125 (__v4di)_mm256_madd52lo_epu64(__X, __Y, __Z),
126 (__v4di)_mm256_setzero_si256());
Michael Zuckerman0190c652016-03-07 09:55:55 +0000127}
128
129
Craig Topper74c10e32018-07-09 19:00:16 +0000130#undef __DEFAULT_FN_ATTRS128
131#undef __DEFAULT_FN_ATTRS256
Michael Zuckerman0190c652016-03-07 09:55:55 +0000132
133#endif