2020#define __DEFAULT_FN_ATTRS256 \
2121 __attribute__ ((__always_inline__, __nodebug__, __target__(" f16c" ), __min_vector_width__(256 )))
2222
23+ #if defined(__cplusplus) && (__cplusplus >= 201103L)
24+ #define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 constexpr
25+ #define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256 constexpr
26+ #else
27+ #define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128
28+ #define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256
29+ #endif
30+
2331/* NOTE: Intel documents the 128-bit versions of these as being in emmintrin.h,
2432 * but that's because icc can emulate these without f16c using a library call.
2533 * Since we don't do that let's leave these in f16cintrin.h.
3543// / \param __a
3644// / A 16-bit half-precision float value.
3745// / \returns The converted 32-bit float value.
38- static __inline float __DEFAULT_FN_ATTRS128
46+ static __inline float __DEFAULT_FN_ATTRS128_CONSTEXPR
3947_cvtsh_ss (unsigned short __a)
4048{
4149 return (float )__builtin_bit_cast (__fp16, __a);
@@ -104,7 +112,7 @@ _cvtsh_ss(unsigned short __a)
104112// / A 128-bit vector containing 16-bit half-precision float values. The lower
105113// / 64 bits are used in the conversion.
106114// / \returns A 128-bit vector of [4 x float] containing converted float values.
107- static __inline __m128 __DEFAULT_FN_ATTRS128
115+ static __inline __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR
108116_mm_cvtph_ps (__m128i __a)
109117{
110118 typedef __fp16 __v4fp16 __attribute__ ((__vector_size__ (8 )));
@@ -151,7 +159,7 @@ _mm_cvtph_ps(__m128i __a)
151159// / converted to 32-bit single-precision float values.
152160// / \returns A vector of [8 x float] containing the converted 32-bit
153161// / single-precision float values.
154- static __inline __m256 __DEFAULT_FN_ATTRS256
162+ static __inline __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR
155163_mm256_cvtph_ps (__m128i __a)
156164{
157165 typedef __fp16 __v8fp16 __attribute__ ((__vector_size__ (16 ), __aligned__ (16 )));
@@ -161,5 +169,7 @@ _mm256_cvtph_ps(__m128i __a)
161169
162170#undef __DEFAULT_FN_ATTRS128
163171#undef __DEFAULT_FN_ATTRS256
172+ #undef __DEFAULT_FN_ATTRS128_CONSTEXPR
173+ #undef __DEFAULT_FN_ATTRS256_CONSTEXPR
164174
165175#endif /* __F16CINTRIN_H */
0 commit comments