================
@@ -3013,6 +3013,62 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
     break;
   }
 
+  case Builtin::BI__builtin_selectvector: {
+    if (checkArgCount(*this, TheCall, 3))
+      return ExprError();
+
+    ExprResult LHS = TheCall->getArg(0);
+    ExprResult RHS = TheCall->getArg(1);
+
+    QualType Result = UsualArithmeticConversions(
+        LHS, RHS, TheCall->getExprLoc(), ACK_Comparison);
+
+    ExprResult Mask = UsualUnaryConversions(TheCall->getArg(2));
+
+    if (LHS.isInvalid() || RHS.isInvalid() || Mask.isInvalid())
+      return ExprError();
+
+    QualType LHST = LHS.get()->getType();
+    QualType RHST = RHS.get()->getType();
+    QualType MaskT = Mask.get()->getType();
+
+    if (Result.isNull() || LHST.getCanonicalType() != RHST.getCanonicalType()) 
{
+      Diag(LHS.get()->getBeginLoc(),
+           diag::err_typecheck_call_different_arg_types)
+          << LHST << RHST;
+      return ExprError();
+    }
+
+    const auto *LHSVecT = LHST->getAs<VectorType>();
+    const auto *MaskVecT = MaskT->getAs<VectorType>();
+
+    if (!LHSVecT) {
+      Diag(LHS.get()->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+          << 1 << 4 << LHST;
----------------
AaronBallman wrote:

Can you add inline comments to the magic numbers (here and below), like 
`/*argument*/1`

https://github.com/llvm/llvm-project/pull/91306
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to