[clang] [X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - Allow AVX/AVX512 IFMA madd52 intrinsics to be used in constexpr (PR #161056)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 28 22:08:32 PDT 2025
================
@@ -3564,6 +3564,28 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
return F;
});
+ case X86::BI__builtin_ia32_vpmadd52luq128:
+ case X86::BI__builtin_ia32_vpmadd52luq256:
+ case X86::BI__builtin_ia32_vpmadd52luq512:
+ return interp__builtin_elementwise_triop(
+ S, OpPC, Call, [](const APSInt &A, const APSInt &B, const APSInt &C) {
+ APSInt result = A * B + C;
+ APSInt mask(APSInt::getAllOnes(52).zext(64), false);
+ APSInt masked_result = result & mask;
+ return APSInt(masked_result, true); // unsigned result
+ });
+ case X86::BI__builtin_ia32_vpmadd52huq128:
+ case X86::BI__builtin_ia32_vpmadd52huq256:
+ case X86::BI__builtin_ia32_vpmadd52huq512:
+ return interp__builtin_elementwise_triop(
+ S, OpPC, Call, [](const APSInt &A, const APSInt &B, const APSInt &C) {
+ APSInt result = A * B + C;
+ APSInt mask(APSInt::getAllOnes(52).zext(64), false);
+ APSInt shifted_result = result >> 52;
----------------
tbaederr wrote:
Some explanation for the magic constants here would be nice I guess.
https://github.com/llvm/llvm-project/pull/161056
More information about the cfe-commits
mailing list