================
@@ -2160,7 +2197,32 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
cast<cir::VectorType>(convertType(e->getArg(0)->getType()))
.getElementType());
case Builtin::BI__builtin_reduce_assoc_fadd:
- case Builtin::BI__builtin_reduce_in_order_fadd:
+ return errorBuiltinNYI(*this, e, builtinID);
+ case Builtin::BI__builtin_reduce_in_order_fadd: {
+ mlir::Value vector = emitScalarExpr(e->getArg(0));
+ auto vectorTy = cast<cir::VectorType>(vector.getType());
+ mlir::Type scalarTy = vectorTy.getElementType();
+ mlir::Value startValue;
+ mlir::Location loc = getLoc(e->getExprLoc());
+ if (e->getNumArgs() == 2) {
+ startValue = emitScalarExpr(e->getArg(1));
+ if (startValue.getType() != scalarTy)
+ startValue =
+ builder.createCast(getLoc(e->getArg(1)->getExprLoc()),
+ cir::CastKind::floating, startValue, scalarTy);
+ } else {
+ auto fpTy = cast<cir::FPTypeInterface>(scalarTy);
+ startValue = cir::ConstantOp::create(
+ builder, loc,
+ cir::FPAttr::get(scalarTy,
+ llvm::APFloat::getZero(fpTy.getFloatSemantics(),
----------------
xakep8 wrote:
Yes I saw that Sema rejects single arg on reduce_in_order_fadd I just left it
there because I was targeting the support for fast-math in
cir::LLVMIntrinsicCallOp but ig for this PR I'll remove that and bring it back
with proper support in the next one.
https://github.com/llvm/llvm-project/pull/224204
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits