[flang-commits] [flang] [flang] Fix for atand(Y, X), and implment atan2d(Y, X), atanpi(X), atanpi(Y, X), atan2pi(Y, X) (PR #79002)

via flang-commits flang-commits at lists.llvm.org
Wed Jan 31 07:35:02 PST 2024


================
@@ -2128,20 +2131,56 @@ IntrinsicLibrary::genAny(mlir::Type resultType,
   return readAndAddCleanUp(resultMutableBox, resultType, "ANY");
 }
 
+// ATAND, ATAN2D
 mlir::Value IntrinsicLibrary::genAtand(mlir::Type resultType,
                                        llvm::ArrayRef<mlir::Value> args) {
-  assert(args.size() == 1);
+  // assert for: atand(X), atand(Y,X), atan2d(Y,X)
+  assert(args.size() >= 1 && args.size() <= 2);
+
   mlir::MLIRContext *context = builder.getContext();
-  mlir::FunctionType ftype =
-      mlir::FunctionType::get(context, {resultType}, {args[0].getType()});
-  mlir::Value atan = getRuntimeCallGenerator("atan", ftype)(builder, loc, args);
+  mlir::Value atan;
+
+  // atand(Y,X) atan2d(Y,X) == atan2(Y,X) * 180/pi
----------------
jeanPerier wrote:

```suggestion
  // atand = atan * 180/pi
```

Is clearer IMHO.

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


More information about the flang-commits mailing list