[clang] [X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add SSE/AVX VPTEST/VTESTPD/VTESTPS intrinsics to be used in constexpr (PR #160428)
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 29 06:08:35 PDT 2025
================
@@ -3647,7 +3707,34 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
S, OpPC, Call, [](const APSInt &F, const APSInt &T, const APSInt &C) {
return ((APInt)C).isNegative() ? T : F;
});
-
+ case X86::BI__builtin_ia32_ptestz128:
+ case X86::BI__builtin_ia32_ptestz256:
+ case X86::BI__builtin_ia32_vtestzps:
+ case X86::BI__builtin_ia32_vtestzps256:
+ case X86::BI__builtin_ia32_vtestzpd:
+ case X86::BI__builtin_ia32_vtestzpd256:
----------------
RKSimon wrote:
ps/pd test only test the signbits - not the full vector.
best way to deal with this is to have specific callbacks for int/ps/pd, so something like this for ps/f32:
```
[](const APInt &A, const APInt &B) {
APInt M = APInt::getSplat(A.getBitwidth(), APInt::getSignMask(32));
return ((A& M) & (B & M)) == 0; }
```
similar for pd (f64) - naturally the logic can be simplified depending on the test op.
https://github.com/llvm/llvm-project/pull/160428
More information about the cfe-commits
mailing list