[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow SSE41 phminposuw intrinsic to be used in constexp (PR #163041)

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 14 12:16:57 PDT 2025


================
@@ -12268,6 +12268,40 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
     return Success(R, E);
   }
 
+  case X86::BI__builtin_ia32_phminposuw128: {
+    APValue Source;
+    if (!Evaluate(Source, Info, E->getArg(0)))
+      return false;
+    unsigned SourceLen = Source.getVectorLength();
+    const VectorType *VT = E->getArg(0)->getType()->castAs<VectorType>();
+    QualType ElemQT = VT->getElementType();
+    unsigned ElemBitWidth = Info.Ctx.getTypeSize(ElemQT);
+
+    APInt MinIndex(ElemBitWidth, 0);
+    APInt MinVal = Source.getVectorElt(0).getInt();
+    for (unsigned I = 0; I != SourceLen; ++I) {
----------------
RKSimon wrote:

```suggestion
    for (unsigned I = 1; I != SourceLen; ++I) {
```

https://github.com/llvm/llvm-project/pull/163041


More information about the cfe-commits mailing list