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

Yi Wu via flang-commits flang-commits at lists.llvm.org
Thu Jan 25 03:18:45 PST 2024


================
@@ -2128,13 +2129,53 @@ IntrinsicLibrary::genAny(mlir::Type resultType,
   return readAndAddCleanUp(resultMutableBox, resultType, "ANY");
 }
 
+// ATAN2D
+mlir::Value IntrinsicLibrary::genAtan2d(mlir::Type resultType,
+                                        llvm::ArrayRef<mlir::Value> args) {
+  assert(args.size() == 2);
+
+  mlir::Value y = fir::getBase(args[0]);
+  mlir::Value x = fir::getBase(args[1]);
+
+  // When Y == 0 X must not be 0
+  mlir::Value zero = builder.createRealZeroConstant(loc, y.getType());
+  mlir::Value cmpYEq0 = builder.create<mlir::arith::CmpFOp>(
+      loc, mlir::arith::CmpFPredicate::UEQ, y, zero);
----------------
yi-wu-arm wrote:

Ahh yes, you are right, both of them should have the zero check. Sorry I get confused with gfortran docs.

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


More information about the flang-commits mailing list