================
@@ -3628,6 +3630,44 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl,
unsigned BuiltinID,
break;
}
+ case Builtin::BI__builtin_reduce_addf:
+ case Builtin::BI__builtin_ordered_reduce_addf: {
+ if (checkArgCountRange(TheCall, 1, 2))
+ return ExprError();
+
+ ExprResult Vec = UsualUnaryConversions(TheCall->getArg(0));
+ if (Vec.isInvalid())
+ return ExprError();
+
+ TheCall->setArg(0, Vec.get());
+
+ QualType ElTy = getVectorElementType(Context, Vec.get()->getType());
+ if (ElTy.isNull() || !ElTy->isRealFloatingType()) {
+ Diag(Vec.get()->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+ << 1 << /* vector of */ 4 << /* no int */ 0 << /* fp */ 1
+ << Vec.get()->getType();
+ return ExprError();
+ }
+
+ if (TheCall->getNumArgs() == 2) {
+ ExprResult StartValue = UsualUnaryConversions(TheCall->getArg(1));
+ if (StartValue.isInvalid())
+ return ExprError();
+
+ if (!StartValue.get()->getType()->isRealFloatingType()) {
----------------
sdesmalen-arm wrote:
The following currently compiles:
```
float reduce(vfloat4 v, double d) {
return __builtin_ordered_reduce_fadd(v, d);
}
```
But I think the return value should at least be large enough to represent the
init-operand, so I would have expected some diagnostic to say that `d` is not a
valid type for the operation.
https://github.com/llvm/llvm-project/pull/176160
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits