[clang] [X86][Clang] Add AVX512 Integer Comparison Intrinsics for constexpr Evaluation (PR #164026)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 19 00:31:08 PDT 2025
================
@@ -3101,6 +3101,62 @@ static bool interp__builtin_vec_set(InterpState &S, CodePtr OpPC,
return true;
}
+static bool interp__builtin_cmp_mask(InterpState &S, CodePtr OpPC,
+ const CallExpr *Call, unsigned ID,
+ bool IsUnsigned) {
+ assert(Call->getNumArgs() == 4);
+
+ APSInt Mask = popToAPSInt(S, Call->getArg(3));
+ APSInt Opcode = popToAPSInt(S, Call->getArg(2));
+ const Pointer &RHS = S.Stk.pop<Pointer>();
+ const Pointer &LHS = S.Stk.pop<Pointer>();
+
+ assert(LHS.getNumElems() == RHS.getNumElems());
+
+ APInt RetMask = APInt::getZero(LHS.getNumElems());
+ unsigned VectorLen = LHS.getNumElems();
+ PrimType ElemT = LHS.getFieldDesc()->getPrimType();
+
+ for (unsigned ElemNum = 0; ElemNum < VectorLen; ++ElemNum) {
+ INT_TYPE_SWITCH_NO_BOOL(ElemT, {
+ const APSInt &A = LHS.elem<T>(ElemNum).toAPSInt();
+ const APSInt &B = RHS.elem<T>(ElemNum).toAPSInt();
+ bool Result = false;
+ switch (Opcode.getExtValue() & 0x7) {
----------------
tbaederr wrote:
None of the code in the `TYPE_SWITCH` macro expansion depends on `T` except the first two lines, so you only need those in the macro.
https://github.com/llvm/llvm-project/pull/164026
More information about the cfe-commits
mailing list