[flang-commits] [flang] [flang] Implement `sinpi` (PR #149525)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Tue Jul 22 10:47:02 PDT 2025
================
@@ -8060,6 +8061,21 @@ mlir::Value IntrinsicLibrary::genSind(mlir::Type resultType,
return getRuntimeCallGenerator("sin", ftype)(builder, loc, {arg});
}
+// SINPI
+mlir::Value IntrinsicLibrary::genSinpi(mlir::Type resultType,
+ llvm::ArrayRef<mlir::Value> args) {
+ assert(args.size() == 1);
+ mlir::MLIRContext *context = builder.getContext();
+ mlir::FunctionType ftype =
+ mlir::FunctionType::get(context, {resultType}, {args[0].getType()});
+ llvm::APFloat pi = llvm::APFloat(llvm::numbers::pi);
+ mlir::Value dfactor =
+ builder.createRealConstant(loc, mlir::Float64Type::get(context), pi);
+ mlir::Value factor = builder.createConvert(loc, args[0].getType(), dfactor);
----------------
vzakhari wrote:
Diverge in what sense?
If we "lower" the f32/f64 cases here as `sin(PI * x)`, and the f128 case in Flang's `quadmath` as `sinq(M_PIq * x)`, then they should be pretty consistent, right?
https://github.com/llvm/llvm-project/pull/149525
More information about the flang-commits
mailing list