diff --git a/clang/include/clang/Basic/BuiltinsX86.td b/clang/include/clang/Basic/BuiltinsX86.td index 98cea35beb0ea..df6ec01959bd4 100644 --- a/clang/include/clang/Basic/BuiltinsX86.td +++ b/clang/include/clang/Basic/BuiltinsX86.td @@ -24,12 +24,12 @@ def undef128 : X86Builtin<"_Vector<2, double>()"> { let Attributes = [Const, NoThrow, RequiredVectorWidth<128>]; } -def undef256 : X86Builtin<"_Vector<4, double>()"> { - let Attributes = [Const, NoThrow, RequiredVectorWidth<256>]; +def undef256 : X86Builtin<"_Vector<4, double>()" > { + let Attributes = [Const, Constexpr, NoThrow, RequiredVectorWidth<256>]; } def undef512 : X86Builtin<"_Vector<8, double>()"> { - let Attributes = [Const, NoThrow, RequiredVectorWidth<512>]; + let Attributes = [Const, Constexpr, NoThrow, RequiredVectorWidth<512>]; } // FLAGS @@ -166,7 +166,7 @@ let Features = "sse2", Attributes = [NoThrow] in { def movnti : X86Builtin<"void(int *, int)">; } -let Features = "sse2", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in { +let Features = "sse2", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in { def psadbw128 : X86Builtin<"_Vector<2, long long int>(_Vector<16, char>, _Vector<16, char>)">; def cvtpd2dq : X86Builtin<"_Vector<2, long long int>(_Vector<2, double>)">; def cvtpd2ps : X86Builtin<"_Vector<4, float>(_Vector<2, double>)">; @@ -462,7 +462,7 @@ let Features = "avx", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWid def vpermilvarps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, int>)">; } -let Features = "avx", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in { +let Features = "avx", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in { def dpps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Constant char)">; def cmppd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>, _Constant char)">; def cmpps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Constant char)">; @@ -1004,7 +1004,7 @@ let Features = "avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128 def cmppd128_mask : X86Builtin<"unsigned char(_Vector<2, double>, _Vector<2, double>, _Constant int, unsigned char)">; } -let Features = "avx512f", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in { +let Features = "avx512f", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in { def rndscaleps_mask : X86Builtin<"_Vector<16, float>(_Vector<16, float>, _Constant int, _Vector<16, float>, unsigned short, _Constant int)">; def rndscalepd_mask : X86Builtin<"_Vector<8, double>(_Vector<8, double>, _Constant int, _Vector<8, double>, unsigned char, _Constant int)">; def cvtps2dq512_mask : X86Builtin<"_Vector<16, int>(_Vector<16, float>, _Vector<16, int>, unsigned short, _Constant int)">; @@ -1452,7 +1452,7 @@ let Features = "avx512vl", Attributes = [NoThrow, RequiredVectorWidth<256>] in { def compressstoresi256_mask : X86Builtin<"void(_Vector<8, int *>, _Vector<8, int>, unsigned char)">; } -let Features = "avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in { +let Features = "avx512vl", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in { def cvtpd2dq128_mask : X86Builtin<"_Vector<4, int>(_Vector<2, double>, _Vector<4, int>, unsigned char)">; def cvtpd2ps_mask : X86Builtin<"_Vector<4, float>(_Vector<2, double>, _Vector<4, float>, unsigned char)">; def cvtpd2udq128_mask : X86Builtin<"_Vector<4, int>(_Vector<2, double>, _Vector<4, int>, unsigned char)">; @@ -3287,7 +3287,7 @@ let Features = "avx512bw,avx512vl", def cvtw2mask256 : X86Builtin<"unsigned short(_Vector<16, short>)">; } -let Features = "avx512f", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in { +let Features = "avx512f", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in { def cvtsd2ss_round_mask : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<2, double>, _Vector<4, float>, unsigned char, _Constant int)">; def cvtsi2ss32 : X86Builtin<"_Vector<4, float>(_Vector<4, float>, int, _Constant int)">; def cvtss2sd_round_mask : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<4, float>, _Vector<2, double>, unsigned char, _Constant int)">; diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index b986ee6ca4fa3..ee82398d7ac2a 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -12165,7 +12165,36 @@ static bool evalShuffleGeneric( Out = APValue(ResultElements.data(), ResultElements.size()); return true; } +static bool ConvertDoubleToFloatStrict(EvalInfo &Info, const Expr *E, + APFloat OrigVal, APValue &Result) { + if (OrigVal.isInfinity()) { + Info.CCEDiag(E, diag::note_constexpr_float_arithmetic) << 0; + return false; + } + if (OrigVal.isNaN()) { + Info.CCEDiag(E, diag::note_constexpr_float_arithmetic) << 1; + return false; + } + + APFloat Val = OrigVal; + bool LosesInfo = false; + APFloat::opStatus Status = Val.convert( + APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &LosesInfo); + + if (LosesInfo || Val.isDenormal()) { + Info.CCEDiag(E, diag::note_constexpr_float_arithmetic_strict); + return false; + } + + if (Status != APFloat::opOK) { + Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr); + return false; + } + + Result = APValue(Val); + return true; +} static bool evalShiftWithCount( EvalInfo &Info, const CallExpr *Call, APValue &Out, llvm::function_ref ShiftOp, @@ -12924,6 +12953,120 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) { return Success(APValue(ResultElements.data(), ResultElements.size()), E); } + + case X86::BI__builtin_ia32_cvtsd2ss: { + APValue VecA, VecB; + if (!EvaluateAsRValue(Info, E->getArg(0), VecA) || + !EvaluateAsRValue(Info, E->getArg(1), VecB)) + return false; + + SmallVector Elements; + + APValue ResultVal; + if (!ConvertDoubleToFloatStrict(Info, E, VecB.getVectorElt(0).getFloat(), + ResultVal)) + return false; + + Elements.push_back(ResultVal); + + unsigned NumEltsA = VecA.getVectorLength(); + for (unsigned I = 1; I < NumEltsA; ++I) { + Elements.push_back(VecA.getVectorElt(I)); + } + + return Success(Elements, E); + } + case X86::BI__builtin_ia32_cvtsd2ss_round_mask: { + APValue VecA, VecB, VecSrc, MaskValue; + + if (!EvaluateAsRValue(Info, E->getArg(0), VecA) || + !EvaluateAsRValue(Info, E->getArg(1), VecB) || + !EvaluateAsRValue(Info, E->getArg(2), VecSrc) || + !EvaluateAsRValue(Info, E->getArg(3), MaskValue)) + return false; + + unsigned Mask = MaskValue.getInt().getZExtValue(); + SmallVector Elements; + + if (Mask & 1) { + APValue ResultVal; + if (!ConvertDoubleToFloatStrict(Info, E, VecB.getVectorElt(0).getFloat(), + ResultVal)) + return false; + Elements.push_back(ResultVal); + } else { + Elements.push_back(VecSrc.getVectorElt(0)); + } + + unsigned NumEltsA = VecA.getVectorLength(); + for (unsigned I = 1; I < NumEltsA; ++I) { + Elements.push_back(VecA.getVectorElt(I)); + } + + return Success(Elements, E); + } + case X86::BI__builtin_ia32_cvtpd2ps: + case X86::BI__builtin_ia32_cvtpd2ps256: + case X86::BI__builtin_ia32_cvtpd2ps_mask: + case X86::BI__builtin_ia32_cvtpd2ps512_mask: { + + const auto BuiltinID = E->getBuiltinCallee(); + bool IsMasked = (BuiltinID == X86::BI__builtin_ia32_cvtpd2ps_mask || + BuiltinID == X86::BI__builtin_ia32_cvtpd2ps512_mask); + + APValue InputValue; + if (!EvaluateAsRValue(Info, E->getArg(0), InputValue)) + return false; + + APValue MergeValue; + unsigned Mask = 0xFFFFFFFF; + bool NeedsMerge = false; + if (IsMasked) { + APValue MaskValue; + if (!EvaluateAsRValue(Info, E->getArg(2), MaskValue)) + return false; + Mask = MaskValue.getInt().getZExtValue(); + auto NumEltsResult = E->getType()->getAs()->getNumElements(); + for (unsigned I = 0; I < NumEltsResult; ++I) { + if (!((Mask >> I) & 1)) { + NeedsMerge = true; + break; + } + } + if (NeedsMerge) { + if (!EvaluateAsRValue(Info, E->getArg(1), MergeValue)) + return false; + } + } + + unsigned NumEltsResult = + E->getType()->getAs()->getNumElements(); + unsigned NumEltsInput = InputValue.getVectorLength(); + SmallVector Elements; + for (unsigned I = 0; I < NumEltsResult; ++I) { + if (IsMasked && !((Mask >> I) & 1)) { + if (!NeedsMerge) { + return false; + } + Elements.push_back(MergeValue.getVectorElt(I)); + continue; + } + + if (I >= NumEltsInput) { + Elements.push_back(APValue(APFloat::getZero(APFloat::IEEEsingle()))); + continue; + } + + APValue ResultVal; + if (!ConvertDoubleToFloatStrict( + Info, E, InputValue.getVectorElt(I).getFloat(), ResultVal)) + return false; + + Elements.push_back(ResultVal); + } + return Success(Elements, E); + } + case X86::BI__builtin_ia32_shufps: case X86::BI__builtin_ia32_shufps256: case X86::BI__builtin_ia32_shufps512: { diff --git a/clang/lib/Headers/avx512fintrin.h b/clang/lib/Headers/avx512fintrin.h index 806a13c414c10..63031c2fcfd82 100644 --- a/clang/lib/Headers/avx512fintrin.h +++ b/clang/lib/Headers/avx512fintrin.h @@ -207,9 +207,8 @@ _mm512_undefined(void) return (__m512)__builtin_ia32_undef512(); } -static __inline__ __m512 __DEFAULT_FN_ATTRS512 -_mm512_undefined_ps(void) -{ +static __inline__ __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_undefined_ps(void) { return (__m512)__builtin_ia32_undef512(); } @@ -3489,44 +3488,39 @@ _mm512_mask_cvtepu32lo_pd(__m512d __W, __mmask8 __U, __m512i __A) { (__v8sf)_mm256_setzero_ps(), \ (__mmask8)(U), (int)(R))) -static __inline__ __m256 __DEFAULT_FN_ATTRS512 -_mm512_cvtpd_ps (__m512d __A) -{ +static __inline__ __m256 __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_cvtpd_ps(__m512d __A) { return (__m256) __builtin_ia32_cvtpd2ps512_mask ((__v8df) __A, (__v8sf) _mm256_undefined_ps (), (__mmask8) -1, _MM_FROUND_CUR_DIRECTION); } -static __inline__ __m256 __DEFAULT_FN_ATTRS512 -_mm512_mask_cvtpd_ps (__m256 __W, __mmask8 __U, __m512d __A) -{ +static __inline__ __m256 __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_mask_cvtpd_ps(__m256 __W, __mmask8 __U, __m512d __A) { return (__m256) __builtin_ia32_cvtpd2ps512_mask ((__v8df) __A, (__v8sf) __W, (__mmask8) __U, _MM_FROUND_CUR_DIRECTION); } -static __inline__ __m256 __DEFAULT_FN_ATTRS512 -_mm512_maskz_cvtpd_ps (__mmask8 __U, __m512d __A) -{ +static __inline__ __m256 __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_maskz_cvtpd_ps(__mmask8 __U, __m512d __A) { return (__m256) __builtin_ia32_cvtpd2ps512_mask ((__v8df) __A, (__v8sf) _mm256_setzero_ps (), (__mmask8) __U, _MM_FROUND_CUR_DIRECTION); } -static __inline__ __m512 __DEFAULT_FN_ATTRS512 -_mm512_cvtpd_pslo (__m512d __A) -{ +static __inline__ __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_cvtpd_pslo(__m512d __A) { return (__m512) __builtin_shufflevector((__v8sf) _mm512_cvtpd_ps(__A), (__v8sf) _mm256_setzero_ps (), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); } -static __inline__ __m512 __DEFAULT_FN_ATTRS512 -_mm512_mask_cvtpd_pslo (__m512 __W, __mmask8 __U,__m512d __A) -{ +static __inline__ __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_mask_cvtpd_pslo(__m512 __W, __mmask8 __U, __m512d __A) { return (__m512) __builtin_shufflevector ( (__v8sf) _mm512_mask_cvtpd_ps (_mm512_castps512_ps256(__W), __U, __A), @@ -5382,8 +5376,8 @@ _mm512_kmov (__mmask16 __A) ((long long)__builtin_ia32_vcvtsd2si64((__v2df)(__m128d)(A), (int)(R))) #endif -static __inline__ __m512i - __DEFAULT_FN_ATTRS512_CONSTEXPR _mm512_sll_epi32(__m512i __A, __m128i __B) { +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_sll_epi32(__m512i __A, __m128i __B) { return (__m512i)__builtin_ia32_pslld512((__v16si) __A, (__v4si)__B); } @@ -8654,18 +8648,16 @@ _mm512_mask_compressstoreu_epi32 (void *__P, __mmask16 __U, __m512i __A) (__v4sf)_mm_setzero_ps(), \ (__mmask8)(U), (int)(R))) -static __inline__ __m128 __DEFAULT_FN_ATTRS128 -_mm_mask_cvtsd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128d __B) -{ +static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR +_mm_mask_cvtsd_ss(__m128 __W, __mmask8 __U, __m128 __A, __m128d __B) { return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)__A, (__v2df)__B, (__v4sf)__W, (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); } -static __inline__ __m128 __DEFAULT_FN_ATTRS128 -_mm_maskz_cvtsd_ss (__mmask8 __U, __m128 __A, __m128d __B) -{ +static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR +_mm_maskz_cvtsd_ss(__mmask8 __U, __m128 __A, __m128d __B) { return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)__A, (__v2df)__B, (__v4sf)_mm_setzero_ps(), diff --git a/clang/lib/Headers/avx512vlintrin.h b/clang/lib/Headers/avx512vlintrin.h index 388f99d812312..6e2b19c8a2f7b 100644 --- a/clang/lib/Headers/avx512vlintrin.h +++ b/clang/lib/Headers/avx512vlintrin.h @@ -1791,30 +1791,30 @@ _mm256_maskz_cvtpd_epi32 (__mmask8 __U, __m256d __A) { (__v4si)_mm_setzero_si128()); } -static __inline__ __m128 __DEFAULT_FN_ATTRS128 -_mm_mask_cvtpd_ps (__m128 __W, __mmask8 __U, __m128d __A) { +static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR +_mm_mask_cvtpd_ps(__m128 __W, __mmask8 __U, __m128d __A) { return (__m128) __builtin_ia32_cvtpd2ps_mask ((__v2df) __A, (__v4sf) __W, (__mmask8) __U); } -static __inline__ __m128 __DEFAULT_FN_ATTRS128 -_mm_maskz_cvtpd_ps (__mmask8 __U, __m128d __A) { +static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR +_mm_maskz_cvtpd_ps(__mmask8 __U, __m128d __A) { return (__m128) __builtin_ia32_cvtpd2ps_mask ((__v2df) __A, (__v4sf) _mm_setzero_ps (), (__mmask8) __U); } -static __inline__ __m128 __DEFAULT_FN_ATTRS256 -_mm256_mask_cvtpd_ps (__m128 __W, __mmask8 __U, __m256d __A) { +static __inline__ __m128 __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_mask_cvtpd_ps(__m128 __W, __mmask8 __U, __m256d __A) { return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, (__v4sf)_mm256_cvtpd_ps(__A), (__v4sf)__W); } -static __inline__ __m128 __DEFAULT_FN_ATTRS256 -_mm256_maskz_cvtpd_ps (__mmask8 __U, __m256d __A) { +static __inline__ __m128 __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_maskz_cvtpd_ps(__mmask8 __U, __m256d __A) { return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, (__v4sf)_mm256_cvtpd_ps(__A), (__v4sf)_mm_setzero_ps()); diff --git a/clang/lib/Headers/avxintrin.h b/clang/lib/Headers/avxintrin.h index 54a6e0cd73ab9..605e70307cfc9 100644 --- a/clang/lib/Headers/avxintrin.h +++ b/clang/lib/Headers/avxintrin.h @@ -2186,9 +2186,8 @@ _mm256_cvtepi32_ps(__m256i __a) { /// \param __a /// A 256-bit vector of [4 x double]. /// \returns A 128-bit vector of [4 x float] containing the converted values. -static __inline __m128 __DEFAULT_FN_ATTRS -_mm256_cvtpd_ps(__m256d __a) -{ +static __inline __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm256_cvtpd_ps(__m256d __a) { return (__m128)__builtin_ia32_cvtpd2ps256((__v4df) __a); } @@ -3606,9 +3605,8 @@ _mm256_undefined_pd(void) /// This intrinsic has no corresponding instruction. /// /// \returns A 256-bit vector of [8 x float] containing undefined values. -static __inline__ __m256 __DEFAULT_FN_ATTRS -_mm256_undefined_ps(void) -{ +static __inline__ __m256 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm256_undefined_ps(void) { return (__m256)__builtin_ia32_undef256(); } diff --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h index 9d71c69878e47..1ca7097cd170a 100644 --- a/clang/lib/Headers/emmintrin.h +++ b/clang/lib/Headers/emmintrin.h @@ -1278,7 +1278,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomineq_sd(__m128d __a, /// A 128-bit vector of [2 x double]. /// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the /// converted values. The upper 64 bits are set to zero. -static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_cvtpd_ps(__m128d __a) { +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtpd_ps(__m128d __a) { return __builtin_ia32_cvtpd2ps((__v2df)__a); } @@ -1383,8 +1384,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_cvtsd_si32(__m128d __a) { /// \returns A 128-bit vector of [4 x float]. The lower 32 bits contain the /// converted value from the second parameter. The upper 96 bits are copied /// from the upper 96 bits of the first parameter. -static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_cvtsd_ss(__m128 __a, - __m128d __b) { +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtsd_ss(__m128 __a, __m128d __b) { return (__m128)__builtin_ia32_cvtsd2ss((__v4sf)__a, (__v2df)__b); } diff --git a/clang/test/SemaCXX/constexpr-x86-intrinsics-pd2ps.cpp b/clang/test/SemaCXX/constexpr-x86-intrinsics-pd2ps.cpp new file mode 100644 index 0000000000000..4a1e9a9c5ae2c --- /dev/null +++ b/clang/test/SemaCXX/constexpr-x86-intrinsics-pd2ps.cpp @@ -0,0 +1,479 @@ +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown -target-feature +avx -target-feature +avx512f -target-feature +avx512vl -verify %s + +#define __MM_MALLOC_H +#include + +namespace Test_mm_cvtsd_ss { +namespace OK { +constexpr __m128 a = { 9.0f, 5.0f, 6.0f, 7.0f }; +constexpr __m128d b = { -1.0, 42.0 }; +constexpr __m128 r = _mm_cvtsd_ss(a, b); +static_assert(r[0] == -1.0f && r[1] == 5.0f && r[2] == 6.0f && r[3] == 7.0f, ""); +} +namespace Inexact { +constexpr __m128 a = { 0.0f, 1.0f, 2.0f, 3.0f }; +constexpr __m128d b = { 1.0000000000000002, 0.0 }; +constexpr __m128 r = _mm_cvtsd_ss(a, b); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@emmintrin.h:* {{compile time floating point arithmetic suppressed in strict evaluation modes}} +// expected-note@-3 {{in call to '_mm_cvtsd_ss({0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00}, {1.000000e+00, 0.000000e+00})'}} +} +namespace Inf { +constexpr __m128 a = { 0.0f, 1.0f, 2.0f, 3.0f }; +constexpr __m128d b = { __builtin_huge_val(), 0.0 }; +constexpr __m128 r = _mm_cvtsd_ss(a, b); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@emmintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@-3 {{in call to '_mm_cvtsd_ss({0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00}, {INF, 0.000000e+00})'}} +} +namespace NaN { +constexpr __m128 a = { 0.0f, 1.0f, 2.0f, 3.0f }; +constexpr __m128d b = { __builtin_nan(""), 0.0 }; +constexpr __m128 r = _mm_cvtsd_ss(a, b); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@emmintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@-3 {{in call to '_mm_cvtsd_ss({0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00}, {nan, 0.000000e+00})'}} +} +namespace Subnormal { +constexpr __m128 a = { 0.0f, 1.0f, 2.0f, 3.0f }; +constexpr __m128d b = { 1e-310, 0.0 }; +constexpr __m128 r = _mm_cvtsd_ss(a, b); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@emmintrin.h:* {{compile time floating point arithmetic suppressed in strict evaluation modes}} +// expected-note@-3 {{in call to '_mm_cvtsd_ss({0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00}, {1.000000e-310, 0.000000e+00})'}} +} +} + +namespace Test_mm_mask_cvtsd_ss { +namespace OK { +constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f }; +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b = { -1.0, 42.0 }; +constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x1, a, b); +static_assert(r[0] == -1.0f && r[1] == 2.0f && r[2] == 3.0f && r[3] == 4.0f, ""); +} +namespace MaskOff { +constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f }; +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b = { -1.0, 42.0 }; +constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x0, a, b); +static_assert(r[0] == 9.0f && r[1] == 2.0f, ""); +} +namespace MaskOffInexact { +constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f }; +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b_inexact = { 1.0000000000000002, 0.0 }; +constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x0, a, b_inexact); +static_assert(r[0] == 9.0f, ""); +} +namespace MaskOnInexact { +constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f }; +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b_inexact = { 1.0000000000000002, 0.0 }; +constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x1, a, b_inexact); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{compile time floating point arithmetic suppressed in strict evaluation modes}} +// expected-note@-3 {{in call to '_mm_mask_cvtsd_ss({9.000000e+00, 5.000000e+00, 6.000000e+00, 7.000000e+00}, 1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {1.000000e+00, 0.000000e+00})'}} +} +namespace MaskOnInf { +constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f }; +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b_inf = { __builtin_huge_val(), 0.0 }; +constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x1, a, b_inf); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@-3 {{in call to '_mm_mask_cvtsd_ss({9.000000e+00, 5.000000e+00, 6.000000e+00, 7.000000e+00}, 1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {INF, 0.000000e+00})'}} +} +namespace MaskOnNaN { +constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f }; +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b_nan = { __builtin_nan(""), 0.0 }; +constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x1, a, b_nan); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@-3 {{in call to '_mm_mask_cvtsd_ss({9.000000e+00, 5.000000e+00, 6.000000e+00, 7.000000e+00}, 1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {nan, 0.000000e+00})'}} +} +namespace MaskOnSubnormal { +constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f }; +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b_sub = { 1e-310, 0.0 }; +constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x1, a, b_sub); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{compile time floating point arithmetic suppressed in strict evaluation modes}} +// expected-note@-3 {{in call to '_mm_mask_cvtsd_ss({9.000000e+00, 5.000000e+00, 6.000000e+00, 7.000000e+00}, 1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {1.000000e-310, 0.000000e+00})'}} +} +} + +namespace Test_mm_maskz_cvtsd_ss { +namespace OK { +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b = { -1.0, 42.0 }; +constexpr __m128 r = _mm_maskz_cvtsd_ss(0x1, a, b); +static_assert(r[0] == -1.0f && r[1] == 2.0f, ""); +} +namespace MaskOff { +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b = { -1.0, 42.0 }; +constexpr __m128 r = _mm_maskz_cvtsd_ss(0x0, a, b); +static_assert(r[0] == 0.0f && r[1] == 2.0f, ""); +} +namespace MaskOffInexact { +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b_inexact = { 1.0000000000000002, 0.0 }; +constexpr __m128 r = _mm_maskz_cvtsd_ss(0x0, a, b_inexact); +static_assert(r[0] == 0.0f, ""); +} +namespace MaskOnInf { +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b_inf = { __builtin_huge_val(), 0.0 }; +constexpr __m128 r = _mm_maskz_cvtsd_ss(0x1, a, b_inf); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@-3 {{in call to '_mm_maskz_cvtsd_ss(1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {INF, 0.000000e+00})'}} +} +namespace MaskOnNaN { +constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f }; +constexpr __m128d b_nan = { __builtin_nan(""), 0.0 }; +constexpr __m128 r = _mm_maskz_cvtsd_ss(0x1, a, b_nan); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@-3 {{in call to '_mm_maskz_cvtsd_ss(1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {nan, 0.000000e+00})'}} +} +} + +namespace Test_mm_cvtpd_ps { +namespace OK { +constexpr __m128d a = { -1.0, +2.0 }; +constexpr __m128 r = _mm_cvtpd_ps(a); +static_assert(r[0] == -1.0f && r[1] == +2.0f, ""); +static_assert(r[2] == 0.0f && r[3] == 0.0f, ""); +} +namespace Inexact { +constexpr __m128d a = { 1.0000000000000002, 0.0 }; +constexpr __m128 r = _mm_cvtpd_ps(a); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@emmintrin.h:* {{compile time floating point arithmetic suppressed in strict evaluation modes}} +// expected-note@-3 {{in call to '_mm_cvtpd_ps({1.000000e+00, 0.000000e+00})'}} +} +namespace Inf { +constexpr __m128d a = { __builtin_huge_val(), 0.0 }; +constexpr __m128 r = _mm_cvtpd_ps(a); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@emmintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@-3 {{in call to '_mm_cvtpd_ps({INF, 0.000000e+00})'}} +} +namespace NaN { +constexpr __m128d a = { __builtin_nan(""), 0.0 }; +constexpr __m128 r = _mm_cvtpd_ps(a); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@emmintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@-3 {{in call to '_mm_cvtpd_ps({nan, 0.000000e+00})'}} +} +namespace Subnormal { +constexpr __m128d a = { 1e-310, 0.0 }; +constexpr __m128 r = _mm_cvtpd_ps(a); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@emmintrin.h:* {{compile time floating point arithmetic suppressed in strict evaluation modes}} +// expected-note@-3 {{in call to '_mm_cvtpd_ps({1.000000e-310, 0.000000e+00})'}} +} +} + +namespace Test_mm_mask_cvtpd_ps { +namespace OK { +constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f }; +constexpr __m128d a = { -1.0, +2.0 }; +constexpr __m128 r = _mm_mask_cvtpd_ps(src, 0x3, a); +static_assert(r[0] == -1.0f && r[1] == +2.0f, ""); +static_assert(r[2] == 9.0f && r[3] == 9.0f, ""); +} +namespace Partial { +constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f }; +constexpr __m128d a = { -1.0, +2.0 }; +constexpr __m128 r = _mm_mask_cvtpd_ps(src, 0x1, a); +static_assert(r[0] == -1.0f && r[1] == 9.0f, ""); +} +namespace MaskOffInexact { +constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f }; +constexpr __m128d a_inexact = { -1.0, 1.0000000000000002 }; +constexpr __m128 r = _mm_mask_cvtpd_ps(src, 0x1, a_inexact); +static_assert(r[0] == -1.0f && r[1] == 9.0f, ""); +} +namespace MaskOnInexact { +constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f }; +constexpr __m128d a_inexact = { -1.0, 1.0000000000000002 }; +constexpr __m128 r = _mm_mask_cvtpd_ps(src, 0x2, a_inexact); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512vlintrin.h:* {{compile time floating point arithmetic suppressed in strict evaluation modes}} +// expected-note@-3 {{in call to '_mm_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 2, {-1.000000e+00, 1.000000e+00})'}} +} +namespace MaskOnInf { +constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f }; +constexpr __m128d a_inf = { -1.0, __builtin_huge_val() }; +constexpr __m128 r = _mm_mask_cvtpd_ps(src, 0x2, a_inf); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512vlintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@-3 {{in call to '_mm_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 2, {-1.000000e+00, INF})'}} +} +namespace MaskOnNaN { +constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f }; +constexpr __m128d a_nan = { -1.0, __builtin_nan("") }; +constexpr __m128 r = _mm_mask_cvtpd_ps(src, 0x2, a_nan); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512vlintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@-3 {{in call to '_mm_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 2, {-1.000000e+00, nan})'}} +} +} + +namespace Test_mm_maskz_cvtpd_ps { +namespace OK { +constexpr __m128d a = { -1.0, +2.0 }; +constexpr __m128 r = _mm_maskz_cvtpd_ps(0x1, a); +static_assert(r[0] == -1.0f && r[1] == 0.0f, ""); +static_assert(r[2] == 0.0f && r[3] == 0.0f, ""); +} +namespace MaskOffInexact { +constexpr __m128d a_inexact = { -1.0, 1.0000000000000002 }; +constexpr __m128 r = _mm_maskz_cvtpd_ps(0x1, a_inexact); +static_assert(r[0] == -1.0f && r[1] == 0.0f, ""); +} +namespace MaskOnInf { +constexpr __m128d a_inf = { -1.0, __builtin_huge_val() }; +constexpr __m128 r = _mm_maskz_cvtpd_ps(0x2, a_inf); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512vlintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@-3 {{in call to '_mm_maskz_cvtpd_ps(2, {-1.000000e+00, INF})'}} +} +namespace MaskOnNaN { +constexpr __m128d a_nan = { -1.0, __builtin_nan("") }; +constexpr __m128 r = _mm_maskz_cvtpd_ps(0x2, a_nan); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512vlintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@-3 {{in call to '_mm_maskz_cvtpd_ps(2, {-1.000000e+00, nan})'}} +} +} + +namespace Test_mm256_cvtpd_ps { +namespace OK { +constexpr __m256d a = { 0.0, -1.0, +2.0, +3.5 }; +constexpr __m128 r = _mm256_cvtpd_ps(a); +static_assert(r[0] == 0.0f && r[1] == -1.0f, ""); +static_assert(r[2] == +2.0f && r[3] == +3.5f, ""); +} +namespace Inexact { +constexpr __m256d a = { 1.0000000000000002, 0.0, 0.0, 0.0 }; +constexpr __m128 r = _mm256_cvtpd_ps(a); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avxintrin.h:* {{compile time floating point arithmetic suppressed in strict evaluation modes}} +// expected-note@-3 {{in call to '_mm256_cvtpd_ps({1.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00})'}} +} +} + +namespace Test_mm256_mask_cvtpd_ps { +namespace OK { +constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f }; +constexpr __m256d a = { 0.0, -1.0, +2.0, +3.5 }; +constexpr __m128 r = _mm256_mask_cvtpd_ps(src, 0xF, a); +static_assert(r[0] == 0.0f && r[1] == -1.0f && r[2] == +2.0f && r[3] == +3.5f, ""); +} +namespace MaskOffInf { +// Note: 256-bit masked operations use selectps, which evaluates ALL lanes before masking +// So even masked-off Inf/NaN values cause errors (architectural limitation) +constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f }; +constexpr __m256d a_inf = { -1.0, +2.0, __builtin_huge_val(), +8.0 }; +constexpr __m128 r = _mm256_mask_cvtpd_ps(src, 0x3, a_inf); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avxintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@avx512vlintrin.h:* {{in call to '_mm256_cvtpd_ps({-1.000000e+00, 2.000000e+00, INF, 8.000000e+00})'}} +// expected-note@-4 {{in call to '_mm256_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 3, {-1.000000e+00, 2.000000e+00, INF, 8.000000e+00})'}} +} +namespace MaskOffNaN { +// Note: 256-bit masked operations use selectps, which evaluates ALL lanes before masking +// So even masked-off Inf/NaN values cause errors (architectural limitation) +constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f }; +constexpr __m256d a_nan = { -1.0, +2.0, +4.0, __builtin_nan("") }; +constexpr __m128 r = _mm256_mask_cvtpd_ps(src, 0x7, a_nan); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avxintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@avx512vlintrin.h:* {{in call to '_mm256_cvtpd_ps({-1.000000e+00, 2.000000e+00, 4.000000e+00, nan})'}} +// expected-note@-4 {{in call to '_mm256_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 7, {-1.000000e+00, 2.000000e+00, 4.000000e+00, nan})'}} +} +} + +namespace Test_mm256_maskz_cvtpd_ps { +namespace OK { +constexpr __m256d a = { 0.0, -1.0, +2.0, +3.5 }; +constexpr __m128 r = _mm256_maskz_cvtpd_ps(0x5, a); +static_assert(r[0] == 0.0f && r[1] == 0.0f && r[2] == +2.0f && r[3] == 0.0f, ""); +} +namespace MaskOffInf { +// Note: 256-bit masked operations use selectps, which evaluates ALL lanes before masking +// So even masked-off Inf/NaN values cause errors (architectural limitation) +constexpr __m256d a_inf = { -1.0, +2.0, __builtin_huge_val(), +8.0 }; +constexpr __m128 r = _mm256_maskz_cvtpd_ps(0x3, a_inf); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avxintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@avx512vlintrin.h:* {{in call to '_mm256_cvtpd_ps({-1.000000e+00, 2.000000e+00, INF, 8.000000e+00})'}} +// expected-note@-4 {{in call to '_mm256_maskz_cvtpd_ps(3, {-1.000000e+00, 2.000000e+00, INF, 8.000000e+00})'}} +} +namespace MaskOffNaN { +// Note: 256-bit masked operations use selectps, which evaluates ALL lanes before masking +// So even masked-off Inf/NaN values cause errors (architectural limitation) +constexpr __m256d a_nan = { -1.0, +2.0, +4.0, __builtin_nan("") }; +constexpr __m128 r = _mm256_maskz_cvtpd_ps(0x7, a_nan); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avxintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@avx512vlintrin.h:* {{in call to '_mm256_cvtpd_ps({-1.000000e+00, 2.000000e+00, 4.000000e+00, nan})'}} +// expected-note@-4 {{in call to '_mm256_maskz_cvtpd_ps(7, {-1.000000e+00, 2.000000e+00, 4.000000e+00, nan})'}} +} +} + +namespace Test_mm512_cvtpd_ps { +namespace OK { +constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 }; +constexpr __m256 r = _mm512_cvtpd_ps(a); +static_assert(r[0] == -1.0f && r[7] == +128.0f, ""); +} +namespace Inexact { +constexpr __m512d a = { 1.0000000000000002, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; +constexpr __m256 r = _mm512_cvtpd_ps(a); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{compile time floating point arithmetic suppressed in strict evaluation modes}} +// expected-note@-3 {{in call to '_mm512_cvtpd_ps({1.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00})'}} +} +} + +namespace Test_mm512_mask_cvtpd_ps { +namespace OK { +constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 }; +constexpr __m256 r = _mm512_mask_cvtpd_ps(src, 0x05, a); +static_assert(r[0] == -1.0f && r[2] == +4.0f, ""); +static_assert(r[1] == 9.0f && r[3] == 9.0f, ""); +} +namespace MaskOffInexact { +constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a_inexact = { -1.0, +2.0, +4.0, +8.0, +16.0, 1.0000000000000002, +64.0, +128.0 }; +constexpr __m256 r = _mm512_mask_cvtpd_ps(src, 0b11011111, a_inexact); +static_assert(r[0] == -1.0f && r[5] == 9.0f && r[6] == 64.0f && r[7] == 128.0f, ""); +} +namespace MaskOffInf { +constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a_inf = { -1.0, +2.0, +4.0, +8.0, +16.0, __builtin_huge_val(), +64.0, +128.0 }; +constexpr __m256 r = _mm512_mask_cvtpd_ps(src, 0x1F, a_inf); +static_assert(r[0] == -1.0f && r[4] == 16.0f && r[5] == 9.0f, ""); +} +namespace MaskOffNaN { +constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a_nan = { -1.0, +2.0, +4.0, +8.0, +16.0, __builtin_nan(""), +64.0, +128.0 }; +constexpr __m256 r = _mm512_mask_cvtpd_ps(src, 0x1F, a_nan); +static_assert(r[0] == -1.0f && r[4] == 16.0f && r[5] == 9.0f, ""); +} +namespace MaskOnInf { +constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a_inf = { -1.0, +2.0, +4.0, __builtin_huge_val(), +16.0, +32.0, +64.0, +128.0 }; +constexpr __m256 r = _mm512_mask_cvtpd_ps(src, 0x08, a_inf); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@-3 {{in call to '_mm512_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 8, {-1.000000e+00, 2.000000e+00, 4.000000e+00, INF, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}} +} +namespace MaskOnNaN { +constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a_nan = { -1.0, +2.0, +4.0, __builtin_nan(""), +16.0, +32.0, +64.0, +128.0 }; +constexpr __m256 r = _mm512_mask_cvtpd_ps(src, 0x08, a_nan); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@-3 {{in call to '_mm512_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 8, {-1.000000e+00, 2.000000e+00, 4.000000e+00, nan, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}} +} +} + +namespace Test_mm512_maskz_cvtpd_ps { +namespace OK { +constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 }; +constexpr __m256 r = _mm512_maskz_cvtpd_ps(0x81, a); +static_assert(r[0] == -1.0f && r[7] == +128.0f, ""); +static_assert(r[1] == 0.0f && r[6] == 0.0f, ""); +} +namespace MaskOffInexact { +constexpr __m512d a_inexact = { -1.0, +2.0, +4.0, +8.0, +16.0, 1.0000000000000002, +64.0, +128.0 }; +constexpr __m256 r = _mm512_maskz_cvtpd_ps(0b11011111, a_inexact); +static_assert(r[0] == -1.0f && r[5] == 0.0f && r[6] == 64.0f && r[7] == 128.0f, ""); +} +namespace MaskOffInf { +constexpr __m512d a_inf = { -1.0, +2.0, +4.0, +8.0, +16.0, __builtin_huge_val(), +64.0, +128.0 }; +constexpr __m256 r = _mm512_maskz_cvtpd_ps(0x1F, a_inf); +static_assert(r[0] == -1.0f && r[4] == 16.0f && r[5] == 0.0f, ""); +} +namespace MaskOffNaN { +constexpr __m512d a_nan = { -1.0, +2.0, +4.0, +8.0, +16.0, __builtin_nan(""), +64.0, +128.0 }; +constexpr __m256 r = _mm512_maskz_cvtpd_ps(0x1F, a_nan); +static_assert(r[0] == -1.0f && r[4] == 16.0f && r[5] == 0.0f, ""); +} +namespace MaskOnInf { +constexpr __m512d a_inf = { -1.0, +2.0, +4.0, __builtin_huge_val(), +16.0, +32.0, +64.0, +128.0 }; +constexpr __m256 r = _mm512_maskz_cvtpd_ps(0x08, a_inf); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@-3 {{in call to '_mm512_maskz_cvtpd_ps(8, {-1.000000e+00, 2.000000e+00, 4.000000e+00, INF, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}} +} +namespace MaskOnNaN { +constexpr __m512d a_nan = { -1.0, +2.0, +4.0, __builtin_nan(""), +16.0, +32.0, +64.0, +128.0 }; +constexpr __m256 r = _mm512_maskz_cvtpd_ps(0x08, a_nan); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@-3 {{in call to '_mm512_maskz_cvtpd_ps(8, {-1.000000e+00, 2.000000e+00, 4.000000e+00, nan, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}} +} +} + +namespace Test_mm512_cvtpd_pslo { +namespace OK { +constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 }; +constexpr __m512 r = _mm512_cvtpd_pslo(a); +static_assert(r[0] == -1.0f && r[7] == +128.0f, ""); +static_assert(r[8] == 0.0f && r[15] == 0.0f, ""); +} +} + +namespace Test_mm512_mask_cvtpd_pslo { +namespace OK { +constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f, + 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 }; +constexpr __m512 r = _mm512_mask_cvtpd_pslo(src, 0x3, a); +static_assert(r[0] == -1.0f && r[1] == +2.0f, ""); +static_assert(r[2] == 9.0f && r[3] == 9.0f, ""); +} +namespace MaskOffInf { +constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f, + 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a_inf = { -1.0, +2.0, __builtin_huge_val(), +8.0, +16.0, +32.0, +64.0, +128.0 }; +constexpr __m512 r = _mm512_mask_cvtpd_pslo(src, 0x3, a_inf); +static_assert(r[0] == -1.0f && r[1] == +2.0f && r[2] == 9.0f, ""); +} +namespace MaskOffNaN { +constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f, + 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a_nan = { -1.0, +2.0, +4.0, __builtin_nan(""), +16.0, +32.0, +64.0, +128.0 }; +constexpr __m512 r = _mm512_mask_cvtpd_pslo(src, 0x7, a_nan); +static_assert(r[0] == -1.0f && r[1] == +2.0f && r[2] == 4.0f && r[3] == 9.0f, ""); +} +namespace MaskOnInf { +constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f, + 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a_inf = { -1.0, +2.0, __builtin_huge_val(), +8.0, +16.0, +32.0, +64.0, +128.0 }; +constexpr __m512 r = _mm512_mask_cvtpd_pslo(src, 0x4, a_inf); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces an infinity}} +// expected-note@avx512fintrin.h:* {{in call to '_mm512_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 4, {-1.000000e+00, 2.000000e+00, INF, 8.000000e+00, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}} +// expected-note@-4 {{in call to '_mm512_mask_cvtpd_pslo({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 4, {-1.000000e+00, 2.000000e+00, INF, 8.000000e+00, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}} +} +namespace MaskOnNaN { +constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f, + 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f }; +constexpr __m512d a_nan = { -1.0, +2.0, __builtin_nan(""), +8.0, +16.0, +32.0, +64.0, +128.0 }; +constexpr __m512 r = _mm512_mask_cvtpd_pslo(src, 0x4, a_nan); +// expected-error@-1 {{must be initialized by a constant expression}} +// expected-note@avx512fintrin.h:* {{floating point arithmetic produces a NaN}} +// expected-note@avx512fintrin.h:* {{in call to '_mm512_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 4, {-1.000000e+00, 2.000000e+00, nan, 8.000000e+00, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}} +// expected-note@-4 {{in call to '_mm512_mask_cvtpd_pslo({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 4, {-1.000000e+00, 2.000000e+00, nan, 8.000000e+00, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}} +} +}