[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX/AVX512 subvector insertion intrinsics to be used in constexpr #157709 (PR #158778)
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 16 07:47:46 PDT 2025
================
@@ -2937,6 +2937,50 @@ static bool interp__builtin_elementwise_triop(
return true;
}
+static bool interp__builtin_x86_insert_subvector(InterpState &S, CodePtr OpPC,
+ const CallExpr *Call,
+ unsigned ID) {
+ assert(Call->getNumArgs() == 3);
+
+ PrimType ImmPT = *S.getContext().classify(Call->getArg(2));
+ APSInt ImmAPS = popToAPSInt(S.Stk, ImmPT);
+ uint64_t Index = ImmAPS.getZExtValue();
+
+ const Pointer &SubVec = S.Stk.pop<Pointer>();
+ if (!SubVec.getFieldDesc()->isPrimitiveArray())
+ return false;
+
+ const Pointer &DstVec = S.Stk.pop<Pointer>();
+ if (!DstVec.getFieldDesc()->isPrimitiveArray())
+ return false;
+
+ const Pointer &Result = S.Stk.peek<Pointer>();
+
+ unsigned DstElements = DstVec.getNumElems();
+ unsigned SubElements = SubVec.getNumElems();
+
+ if (SubElements == 0 || DstElements == 0 || (DstElements % SubElements) != 0)
----------------
RKSimon wrote:
This can probably be an assert - sema checking should catch this for use anyhow
https://github.com/llvm/llvm-project/pull/158778
More information about the cfe-commits
mailing list