[flang-commits] [flang] [flang] Implement `sinpi` (PR #149525)

Connector Switch via flang-commits flang-commits at lists.llvm.org
Tue Jul 22 02:36:55 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);
----------------
c8ef wrote:

I mean, by directly using the C23 functions added in glibc.

- https://www.phoronix.com/news/Glibc-2.41-More-C23

Maybe we could use this approach for now and refactor it in a later PR? Other functions, like sind, appear to suffer from the same issue.

https://github.com/llvm/llvm-project/pull/149525


More information about the flang-commits mailing list