[clang] Issue #162051: [X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add AVX512 KTEST/KORTEST intrinsics to be used in constexpr (PR #166103)
Roberto Turrado Camblor via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 4 12:09:02 PST 2025
rturrado wrote:
A couple of questions.
1) `clang/lib/Headers/avx512fintrin.h` implements both `_mm512_kortestc(A, B)` and `_kortestc_mask16_u8(A, B)` in terms of `__builtin_ia32_kortestchi`. However, `_mm512_kortestc` returns an `int` with the value of `A | B`, while `_kortestc_mask16_u8` returns an `unsigned char` with the value `A | B = 0xFFFF`. Wouldn't it be better to have `mm512_kortestc` also as a builtin?
2) I have updated `clang/lib/AST/ByteCode/InterpBuiltin.cpp` adding cases for all the `ktest` and `kortest` instructions, and calling `interp__builtin_elementwise_int_binop`, which returns an `APInt`. Wouldn't it be better to call `interp__builtin_ia32_test_op` and return a `bool` (which could later be casted to an `unsigned char`). A possible `_mm512_kortestc` could indeed call `interp__builtin_elementwise_int_binop` and return an `APInt` of 16 bits.
https://github.com/llvm/llvm-project/pull/166103
More information about the cfe-commits
mailing list