================ @@ -105,35 +136,27 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, if (SemaRef.checkArgCount(TheCall, 3)) return true; - // check if the all arguments have floating representation - for (unsigned i = 0; i < TheCall->getNumArgs(); ++i) { - ExprResult Arg = TheCall->getArg(i); - QualType ArgTy = Arg.get()->getType(); - if (!ArgTy->hasFloatingRepresentation()) { - SemaRef.Diag(Arg.get()->getBeginLoc(), - diag::err_builtin_invalid_arg_type) - << i + 1 << /* scalar or vector */ 5 << /* no int */ 0 << /* fp */ 1 - << ArgTy; - return true; - } - } + if (CheckAllArgsHaveFloatRepresentation(&SemaRef, TheCall)) + return true; - // check if all arguments are of the same type - ExprResult A = TheCall->getArg(0); - ExprResult B = TheCall->getArg(1); - ExprResult C = TheCall->getArg(2); - if (!(SemaRef.getASTContext().hasSameUnqualifiedType(A.get()->getType(), - B.get()->getType()) && - SemaRef.getASTContext().hasSameUnqualifiedType(A.get()->getType(), - C.get()->getType()))) { - SemaRef.Diag(TheCall->getBeginLoc(), - diag::err_vec_builtin_incompatible_vector) - << TheCall->getDirectCallee() << /*useAllTerminology*/ true - << SourceRange(A.get()->getBeginLoc(), C.get()->getEndLoc()); + if (CheckAllArgsHaveSameType(&SemaRef, TheCall)) ---------------- farzonl wrote:
do we need to do CheckAllArgsHaveSameType and CheckAllArgsHaveFloatRepresentation. Two loops over arguments seems unnecesary. Seems like we can just check if the first value has a float representation then do CheckAllArgsHaveSameType https://github.com/llvm/llvm-project/pull/135878 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits