[flang-commits] [flang] f5759ad - [flang] Try to lower math intrinsics to math operations first.

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Fri Jul 22 09:05:27 PDT 2022


Author: Slava Zakharin
Date: 2022-07-22T09:04:44-07:00
New Revision: f5759add702eb0b1243198d7f49b7a010b977f5d

URL: https://github.com/llvm/llvm-project/commit/f5759add702eb0b1243198d7f49b7a010b977f5d
DIFF: https://github.com/llvm/llvm-project/commit/f5759add702eb0b1243198d7f49b7a010b977f5d.diff

LOG: [flang] Try to lower math intrinsics to math operations first.

This commit changes how math intrinsics are lowered: we, first,
try to lower them into MLIR operations or libm calls via
mathOperations table and only then fallback to pgmath runtime calls.

The pgmath fallback is needed, because mathOperations does not
support all intrinsics that pgmath supports. The main purpose
of this change is to get rid of llvmIntrinsics table so that
we do not have to update both llvmIntrinsics and mathOperations
when adding new intrinsic support.

mathOperations lowering should phase out pgmath lowering, when
more operations are available (e.g. power operations being
added in D129809 and D129811; complex type operations from
Complex dialect).

Differential Revision: https://reviews.llvm.org/D130129

Added: 
    flang/test/Intrinsics/math-codegen.fir
    flang/test/Lower/math-lowering.f90

Modified: 
    flang/lib/Lower/IntrinsicCall.cpp
    flang/test/Lower/Intrinsics/abs.f90
    flang/test/Lower/Intrinsics/anint.f90
    flang/test/Lower/Intrinsics/ceiling.f90
    flang/test/Lower/Intrinsics/exp.f90
    flang/test/Lower/Intrinsics/floor.f90
    flang/test/Lower/Intrinsics/log.f90
    flang/test/Lower/Intrinsics/math-runtime-options.f90
    flang/test/Lower/Intrinsics/sign.f90
    flang/test/Lower/array-elemental-calls-2.f90
    flang/test/Lower/array-expression.f90
    flang/test/Lower/dummy-procedure.f90
    flang/test/Lower/power-operator.f90
    flang/test/Lower/sqrt.f90
    flang/test/Lower/trigonometric-intrinsics.f90

Removed: 
    flang/test/Intrinsics/late-math-codegen.fir
    flang/test/Lower/late-math-lowering.f90
    flang/test/Lower/llvm-math.f90


################################################################################
diff  --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp
index 2db221fd31111..53f7d5301aee2 100644
--- a/flang/lib/Lower/IntrinsicCall.cpp
+++ b/flang/lib/Lower/IntrinsicCall.cpp
@@ -994,37 +994,15 @@ static llvm::cl::opt<bool> outlineAllIntrinsics(
 // Math runtime description and matching utility
 //===----------------------------------------------------------------------===//
 
-/// Command line option to control how math operations are lowered
-/// into MLIR.
-/// Going forward, most of the math operations have to be lowered
-/// to some MLIR dialect operations or libm calls, if the corresponding
-/// MLIR operation is not available or not reasonable to create
-/// (e.g. there are no known optimization opportunities for the math
-/// operation in MLIR).
-///
-/// In general, exposing MLIR operations early can potentially enable more
-/// MLIR optimizations.
-llvm::cl::opt<bool> lowerEarlyToLibCall(
-    "lower-math-early",
-    llvm::cl::desc("Controls when to lower Math intrinsics to library calls"),
-    llvm::cl::init(true));
-
 /// Command line option to modify math runtime behavior used to implement
 /// intrinsics. This option applies both to early and late math-lowering modes.
-enum MathRuntimeVersion {
-  fastVersion,
-  relaxedVersion,
-  preciseVersion,
-  llvmOnly
-};
+enum MathRuntimeVersion { fastVersion, relaxedVersion, preciseVersion };
 llvm::cl::opt<MathRuntimeVersion> mathRuntimeVersion(
     "math-runtime", llvm::cl::desc("Select math operations' runtime behavior:"),
     llvm::cl::values(
         clEnumValN(fastVersion, "fast", "use fast runtime behavior"),
         clEnumValN(relaxedVersion, "relaxed", "use relaxed runtime behavior"),
-        clEnumValN(preciseVersion, "precise", "use precise runtime behavior"),
-        clEnumValN(llvmOnly, "llvm",
-                   "only use LLVM intrinsics (may be incomplete)")),
+        clEnumValN(preciseVersion, "precise", "use precise runtime behavior")),
     llvm::cl::init(fastVersion));
 
 struct RuntimeFunction {
@@ -1271,59 +1249,6 @@ static constexpr MathOperation mathOperations[] = {
     {"tanh", "tanh", genF64F64FuncType, genMathOp<mlir::math::TanhOp>},
 };
 
-// Note: These are also defined as operations in LLVM dialect. See if this
-// can be use and has advantages.
-// TODO: remove this table, since the late math lowering should
-//       replace it and generate proper MLIR operations rather
-//       than llvm intrinsic calls, which still look like generic
-//       calls to MLIR and do not enable many optimizations.
-//       When late math lowering is able to handle all math operations
-//       described in pgmath.h.inc and in the table below, we can
-//       switch to it by default.
-static constexpr RuntimeFunction llvmIntrinsics[] = {
-    {"abs", "llvm.fabs.f32", genF32F32FuncType},
-    {"abs", "llvm.fabs.f64", genF64F64FuncType},
-    {"abs", "llvm.fabs.f128", genF128F128FuncType},
-    {"aint", "llvm.trunc.f32", genF32F32FuncType},
-    {"aint", "llvm.trunc.f64", genF64F64FuncType},
-    {"anint", "llvm.round.f32", genF32F32FuncType},
-    {"anint", "llvm.round.f64", genF64F64FuncType},
-    {"atan", "atanf", genF32F32FuncType},
-    {"atan", "atan", genF64F64FuncType},
-    // ceil is used for CEILING but is 
diff erent, it returns a real.
-    {"ceil", "llvm.ceil.f32", genF32F32FuncType},
-    {"ceil", "llvm.ceil.f64", genF64F64FuncType},
-    {"cos", "llvm.cos.f32", genF32F32FuncType},
-    {"cos", "llvm.cos.f64", genF64F64FuncType},
-    {"cosh", "coshf", genF32F32FuncType},
-    {"cosh", "cosh", genF64F64FuncType},
-    {"exp", "llvm.exp.f32", genF32F32FuncType},
-    {"exp", "llvm.exp.f64", genF64F64FuncType},
-    // llvm.floor is used for FLOOR, but returns real.
-    {"floor", "llvm.floor.f32", genF32F32FuncType},
-    {"floor", "llvm.floor.f64", genF64F64FuncType},
-    {"log", "llvm.log.f32", genF32F32FuncType},
-    {"log", "llvm.log.f64", genF64F64FuncType},
-    {"log10", "llvm.log10.f32", genF32F32FuncType},
-    {"log10", "llvm.log10.f64", genF64F64FuncType},
-    {"nint", "llvm.lround.i64.f64", genIntF64FuncType<64>},
-    {"nint", "llvm.lround.i64.f32", genIntF32FuncType<64>},
-    {"nint", "llvm.lround.i32.f64", genIntF64FuncType<32>},
-    {"nint", "llvm.lround.i32.f32", genIntF32FuncType<32>},
-    {"pow", "llvm.pow.f32", genF32F32F32FuncType},
-    {"pow", "llvm.pow.f64", genF64F64F64FuncType},
-    {"sign", "llvm.copysign.f32", genF32F32F32FuncType},
-    {"sign", "llvm.copysign.f64", genF64F64F64FuncType},
-    {"sign", "llvm.copysign.f80", genF80F80F80FuncType},
-    {"sign", "llvm.copysign.f128", genF128F128F128FuncType},
-    {"sin", "llvm.sin.f32", genF32F32FuncType},
-    {"sin", "llvm.sin.f64", genF64F64FuncType},
-    {"sinh", "sinhf", genF32F32FuncType},
-    {"sinh", "sinh", genF64F64FuncType},
-    {"sqrt", "llvm.sqrt.f32", genF32F32FuncType},
-    {"sqrt", "llvm.sqrt.f64", genF64F64FuncType},
-};
-
 // This helper class computes a "distance" between two function types.
 // The distance measures how many narrowing conversions of actual arguments
 // and result of "from" must be made in order to use "to" instead of "from".
@@ -1592,35 +1517,19 @@ static mlir::func::FuncOp getRuntimeFunction(mlir::Location loc,
   static constexpr RtMap pgmathP(pgmathPrecise);
   static_assert(pgmathP.Verify() && "map must be sorted");
 
-  if (mathRuntimeVersion == fastVersion) {
+  if (mathRuntimeVersion == fastVersion)
     match = searchFunctionInLibrary(loc, builder, pgmathF, name, funcType,
                                     &bestNearMatch, bestMatchDistance);
-  } else if (mathRuntimeVersion == relaxedVersion) {
+  else if (mathRuntimeVersion == relaxedVersion)
     match = searchFunctionInLibrary(loc, builder, pgmathR, name, funcType,
                                     &bestNearMatch, bestMatchDistance);
-  } else if (mathRuntimeVersion == preciseVersion) {
+  else if (mathRuntimeVersion == preciseVersion)
     match = searchFunctionInLibrary(loc, builder, pgmathP, name, funcType,
                                     &bestNearMatch, bestMatchDistance);
-  } else {
-    assert(mathRuntimeVersion == llvmOnly && "unknown math runtime");
-  }
-  if (match)
-    return match;
-
-  // Go through llvm intrinsics if not exact match in libpgmath or if
-  // mathRuntimeVersion == llvmOnly
-  static constexpr RtMap llvmIntr(llvmIntrinsics);
-  static_assert(llvmIntr.Verify() && "map must be sorted");
-  if (mlir::func::FuncOp exactMatch =
-          searchFunctionInLibrary(loc, builder, llvmIntr, name, funcType,
-                                  &bestNearMatch, bestMatchDistance))
-    return exactMatch;
-
-  if (bestNearMatch != nullptr) {
-    checkPrecisionLoss(name, funcType, bestMatchDistance, loc);
-    return getFuncOp(loc, builder, *bestNearMatch);
-  }
-  return {};
+  else
+    llvm_unreachable("unsupported mathRuntimeVersion");
+
+  return match;
 }
 
 /// Helpers to get function type from arguments and result type.
@@ -2010,24 +1919,37 @@ IntrinsicLibrary::getRuntimeCallGenerator(llvm::StringRef name,
   mlir::func::FuncOp funcOp;
   mlir::FunctionType actualFuncType;
   const MathOperation *mathOp = nullptr;
-  if (!lowerEarlyToLibCall) {
-    // Look for a dedicated math operation generator, which
-    // normally produces a single MLIR operation implementing
-    // the math operation.
-    // If not found fall back to a runtime function lookup.
-    const MathOperation *bestNearMatch = nullptr;
-    FunctionDistance bestMatchDistance;
-    mathOp = searchMathOperation(builder, name, soughtFuncType, &bestNearMatch,
-                                 bestMatchDistance);
-    if (!mathOp && bestNearMatch) {
-      // Use the best near match, optionally issuing an error,
-      // if types conversions cause precision loss.
+
+  // Look for a dedicated math operation generator, which
+  // normally produces a single MLIR operation implementing
+  // the math operation.
+  // If not found fall back to a runtime function lookup.
+  const MathOperation *bestNearMatch = nullptr;
+  FunctionDistance bestMatchDistance;
+  mathOp = searchMathOperation(builder, name, soughtFuncType, &bestNearMatch,
+                               bestMatchDistance);
+  if (!mathOp && bestNearMatch) {
+    // Use the best near match, optionally issuing an error,
+    // if types conversions cause precision loss.
+    bool useBestNearMatch = true;
+    // TODO: temporary workaround to avoid using math::PowFOp
+    //       for pow(fp, i64) case and fall back to pgmath runtime.
+    //       When proper Math dialect operations are available
+    //       and added into mathOperations table, this can be removed.
+    //       This is WIP in D129812.
+    if (name == "pow" && soughtFuncType.getInput(0).isa<mlir::FloatType>())
+      if (auto exponentTy =
+              soughtFuncType.getInput(1).dyn_cast<mlir::IntegerType>())
+        useBestNearMatch = exponentTy.getWidth() != 64;
+
+    if (useBestNearMatch) {
       checkPrecisionLoss(name, soughtFuncType, bestMatchDistance, loc);
       mathOp = bestNearMatch;
     }
-    if (mathOp)
-      actualFuncType = mathOp->typeGenerator(builder.getContext());
   }
+  if (mathOp)
+    actualFuncType = mathOp->typeGenerator(builder.getContext());
+
   if (!mathOp)
     if ((funcOp = getRuntimeFunction(loc, builder, name, soughtFuncType)))
       actualFuncType = funcOp.getFunctionType();
@@ -4529,7 +4451,7 @@ mlir::Value Fortran::lower::genPow(fir::FirOpBuilder &builder,
                                    mlir::Value x, mlir::Value y) {
   // TODO: since there is no libm version of pow with integer exponent,
   //       we have to provide an alternative implementation for
-  //       "precise/strict" FP mode and (!lowerEarlyToLibCall).
+  //       "precise/strict" FP mode.
   //       One option is to generate internal function with inlined
   //       implementation and mark it 'strictfp'.
   //       Another option is to implement it in Fortran runtime library

diff  --git a/flang/test/Intrinsics/late-math-codegen.fir b/flang/test/Intrinsics/math-codegen.fir
similarity index 100%
rename from flang/test/Intrinsics/late-math-codegen.fir
rename to flang/test/Intrinsics/math-codegen.fir

diff  --git a/flang/test/Lower/Intrinsics/abs.f90 b/flang/test/Lower/Intrinsics/abs.f90
index dd166fe97192a..ee8be65f89d0c 100644
--- a/flang/test/Lower/Intrinsics/abs.f90
+++ b/flang/test/Lower/Intrinsics/abs.f90
@@ -36,7 +36,7 @@ subroutine abs_testi16(a, b)
 subroutine abs_testh(a, b)
 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f16>
 ! CHECK: %[[VAL_2_1:.*]] = fir.convert %[[VAL_2]] : (f16) -> f32
-! CHECK: %[[VAL_3:.*]] = fir.call @llvm.fabs.f32(%[[VAL_2_1]]) : (f32) -> f32
+! CHECK: %[[VAL_3:.*]] = math.abs %[[VAL_2_1]] : f32
 ! CHECK: %[[VAL_3_1:.*]] = fir.convert %[[VAL_3]] : (f32) -> f16
 ! CHECK: fir.store %[[VAL_3_1]] to %[[VAL_1]] : !fir.ref<f16>
 ! CHECK: return
@@ -49,7 +49,7 @@ subroutine abs_testh(a, b)
 subroutine abs_testb(a, b)
 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<bf16>
 ! CHECK: %[[VAL_2_1:.*]] = fir.convert %[[VAL_2]] : (bf16) -> f32
-! CHECK: %[[VAL_3:.*]] = fir.call @llvm.fabs.f32(%[[VAL_2_1]]) : (f32) -> f32
+! CHECK: %[[VAL_3:.*]] = math.abs %[[VAL_2_1]] : f32
 ! CHECK: %[[VAL_3_1:.*]] = fir.convert %[[VAL_3]] : (f32) -> bf16
 ! CHECK: fir.store %[[VAL_3_1]] to %[[VAL_1]] : !fir.ref<bf16>
 ! CHECK: return
@@ -61,7 +61,7 @@ subroutine abs_testb(a, b)
 ! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<f32>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f32>{{.*}}) {
 subroutine abs_testr(a, b)
 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f32>
-! CHECK: %[[VAL_3:.*]] = fir.call @llvm.fabs.f32(%[[VAL_2]]) : (f32) -> f32
+! CHECK: %[[VAL_3:.*]] = math.abs %[[VAL_2]] : f32
 ! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f32>
 ! CHECK: return
   real :: a, b
@@ -72,7 +72,7 @@ subroutine abs_testr(a, b)
 ! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<f64>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f64>{{.*}}) {
 subroutine abs_testd(a, b)
 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f64>
-! CHECK: %[[VAL_3:.*]] = fir.call @llvm.fabs.f64(%[[VAL_2]]) : (f64) -> f64
+! CHECK: %[[VAL_3:.*]] = math.abs %[[VAL_2]] : f64
 ! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f64>
 ! CHECK: return
   real(kind=8) :: a, b
@@ -83,7 +83,7 @@ subroutine abs_testd(a, b)
 ! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<f128>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f128>{{.*}}) {
 subroutine abs_testr16(a, b)
 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f128>
-! CHECK: %[[VAL_3:.*]] = fir.call @llvm.fabs.f128(%[[VAL_2]]) : (f128) -> f128
+! CHECK: %[[VAL_3:.*]] = math.abs %[[VAL_2]] : f128
 ! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f128>
 ! CHECK: return
   real(kind=16) :: a, b
@@ -96,7 +96,7 @@ subroutine abs_testzr(a, b)
 ! CHECK:  %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.complex<4>>
 ! CHECK:  %[[VAL_3:.*]] = fir.extract_value %[[VAL_2]], [0 : index] : (!fir.complex<4>) -> f32
 ! CHECK:  %[[VAL_4:.*]] = fir.extract_value %[[VAL_2]], [1 : index] : (!fir.complex<4>) -> f32
-! CHECK:  %[[VAL_5:.*]] = fir.call @__mth_i_hypot(%[[VAL_3]], %[[VAL_4]]) : (f32, f32) -> f32
+! CHECK:  %[[VAL_5:.*]] = fir.call @hypotf(%[[VAL_3]], %[[VAL_4]]) : (f32, f32) -> f32
 ! CHECK:  fir.store %[[VAL_5]] to %[[VAL_1]] : !fir.ref<f32>
 ! CHECK:  return
   complex :: a
@@ -110,7 +110,7 @@ subroutine abs_testzd(a, b)
 ! CHECK:  %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.complex<8>>
 ! CHECK:  %[[VAL_3:.*]] = fir.extract_value %[[VAL_2]], [0 : index] : (!fir.complex<8>) -> f64
 ! CHECK:  %[[VAL_4:.*]] = fir.extract_value %[[VAL_2]], [1 : index] : (!fir.complex<8>) -> f64
-! CHECK:  %[[VAL_5:.*]] = fir.call @__mth_i_dhypot(%[[VAL_3]], %[[VAL_4]]) : (f64, f64) -> f64
+! CHECK:  %[[VAL_5:.*]] = fir.call @hypot(%[[VAL_3]], %[[VAL_4]]) : (f64, f64) -> f64
 ! CHECK:  fir.store %[[VAL_5]] to %[[VAL_1]] : !fir.ref<f64>
 ! CHECK:  return
   complex(kind=8) :: a

diff  --git a/flang/test/Lower/Intrinsics/anint.f90 b/flang/test/Lower/Intrinsics/anint.f90
index 7199796710f15..29670b098dea0 100644
--- a/flang/test/Lower/Intrinsics/anint.f90
+++ b/flang/test/Lower/Intrinsics/anint.f90
@@ -3,7 +3,7 @@
 ! CHECK-LABEL: anint_test
 subroutine anint_test(a, b)
   real :: a, b
-  ! CHECK: fir.call @llvm.round.f32
+  ! CHECK: "llvm.intr.round"
   b = anint(a)
 end subroutine
-  
\ No newline at end of file
+  

diff  --git a/flang/test/Lower/Intrinsics/ceiling.f90 b/flang/test/Lower/Intrinsics/ceiling.f90
index 11a91c863a596..8c283de762e28 100644
--- a/flang/test/Lower/Intrinsics/ceiling.f90
+++ b/flang/test/Lower/Intrinsics/ceiling.f90
@@ -5,7 +5,7 @@ subroutine ceiling_test1(i, a)
     integer :: i
     real :: a
     i = ceiling(a)
-    ! CHECK: %[[f:.*]] = fir.call @llvm.ceil.f32
+    ! CHECK: %[[f:.*]] = math.ceil %{{.*}} : f32
     ! CHECK: fir.convert %[[f]] : (f32) -> i32
   end subroutine
   ! CHECK-LABEL: ceiling_test2
@@ -13,8 +13,8 @@ subroutine ceiling_test2(i, a)
     integer(8) :: i
     real :: a
     i = ceiling(a, 8)
-    ! CHECK: %[[f:.*]] = fir.call @llvm.ceil.f32
+    ! CHECK: %[[f:.*]] = math.ceil %{{.*}} : f32
     ! CHECK: fir.convert %[[f]] : (f32) -> i64
   end subroutine
   
-  
\ No newline at end of file
+  

diff  --git a/flang/test/Lower/Intrinsics/exp.f90 b/flang/test/Lower/Intrinsics/exp.f90
index 8d7a6358bda35..a7dac0fbd3337 100644
--- a/flang/test/Lower/Intrinsics/exp.f90
+++ b/flang/test/Lower/Intrinsics/exp.f90
@@ -43,12 +43,12 @@ subroutine exp_testcd(a, b)
 
 ! CHECK-LABEL: private @fir.exp.f32.f32
 ! CHECK-SAME: (%[[ARG32_OUTLINE:.*]]: f32) -> f32
-! CHECK: %[[RESULT32_OUTLINE:.*]] = fir.call @__fs_exp_1(%[[ARG32_OUTLINE]]) : (f32) -> f32
+! CHECK: %[[RESULT32_OUTLINE:.*]] = math.exp %[[ARG32_OUTLINE]] : f32
 ! CHECK: return %[[RESULT32_OUTLINE]] : f32
 
 ! CHECK-LABEL: private @fir.exp.f64.f64
 ! CHECK-SAME: (%[[ARG64_OUTLINE:.*]]: f64) -> f64
-! CHECK: %[[RESULT64_OUTLINE:.*]] = fir.call @__fd_exp_1(%[[ARG64_OUTLINE]]) : (f64) -> f64
+! CHECK: %[[RESULT64_OUTLINE:.*]] = math.exp %[[ARG64_OUTLINE]] : f64
 ! CHECK: return %[[RESULT64_OUTLINE]] : f64
 
 ! CHECK-LABEL: private @fir.exp.z4.z4

diff  --git a/flang/test/Lower/Intrinsics/floor.f90 b/flang/test/Lower/Intrinsics/floor.f90
index a793b04048a27..63d6d2fccee86 100644
--- a/flang/test/Lower/Intrinsics/floor.f90
+++ b/flang/test/Lower/Intrinsics/floor.f90
@@ -5,7 +5,7 @@ subroutine floor_test1(i, a)
     integer :: i
     real :: a
     i = floor(a)
-    ! CHECK: %[[f:.*]] = fir.call @llvm.floor.f32
+    ! CHECK: %[[f:.*]] = math.floor %{{.*}} : f32
     ! CHECK: fir.convert %[[f]] : (f32) -> i32
   end subroutine
   ! CHECK-LABEL: floor_test2
@@ -13,7 +13,7 @@ subroutine floor_test2(i, a)
     integer(8) :: i
     real :: a
     i = floor(a, 8)
-    ! CHECK: %[[f:.*]] = fir.call @llvm.floor.f32
+    ! CHECK: %[[f:.*]] = math.floor %{{.*}} : f32
     ! CHECK: fir.convert %[[f]] : (f32) -> i64
   end subroutine
-  
\ No newline at end of file
+  

diff  --git a/flang/test/Lower/Intrinsics/log.f90 b/flang/test/Lower/Intrinsics/log.f90
index c8d13ef71c202..cf3c1f02d5a28 100644
--- a/flang/test/Lower/Intrinsics/log.f90
+++ b/flang/test/Lower/Intrinsics/log.f90
@@ -63,12 +63,12 @@ subroutine log10_testd(a, b)
 
 ! CHECK-LABEL: private @fir.log.f32.f32
 ! CHECK-SAME: (%[[ARG32_OUTLINE:.*]]: f32) -> f32
-! CHECK: %[[RESULT32_OUTLINE:.*]] = fir.call @__fs_log_1(%[[ARG32_OUTLINE]]) : (f32) -> f32
+! CHECK: %[[RESULT32_OUTLINE:.*]] = math.log %[[ARG32_OUTLINE]] : f32
 ! CHECK: return %[[RESULT32_OUTLINE]] : f32
 
 ! CHECK-LABEL: private @fir.log.f64.f64
 ! CHECK-SAME: (%[[ARG64_OUTLINE:.*]]: f64) -> f64
-! CHECK: %[[RESULT64_OUTLINE:.*]] = fir.call @__fd_log_1(%[[ARG64_OUTLINE]]) : (f64) -> f64
+! CHECK: %[[RESULT64_OUTLINE:.*]] = math.log %[[ARG64_OUTLINE]] : f64
 ! CHECK: return %[[RESULT64_OUTLINE]] : f64
 
 ! CHECK-LABEL: private @fir.log.z4.z4
@@ -83,10 +83,10 @@ subroutine log10_testd(a, b)
 
 ! CHECK-LABEL: private @fir.log10.f32.f32
 ! CHECK-SAME: (%[[ARG32_OUTLINE:.*]]: f32) -> f32
-! CHECK: %[[RESULT32_OUTLINE:.*]] = fir.call @__fs_log10_1(%[[ARG32_OUTLINE]]) : (f32) -> f32
+! CHECK: %[[RESULT32_OUTLINE:.*]] = math.log10 %[[ARG32_OUTLINE]] : f32
 ! CHECK: return %[[RESULT32_OUTLINE]] : f32
 
 ! CHECK-LABEL: private @fir.log10.f64.f64
 ! CHECK-SAME: (%[[ARG64_OUTLINE:.*]]: f64) -> f64
-! CHECK: %[[RESULT64_OUTLINE:.*]] = fir.call @__fd_log10_1(%[[ARG64_OUTLINE]]) : (f64) -> f64
+! CHECK: %[[RESULT64_OUTLINE:.*]] = math.log10 %[[ARG64_OUTLINE]] : f64
 ! CHECK: return %[[RESULT64_OUTLINE]] : f64

diff  --git a/flang/test/Lower/Intrinsics/math-runtime-options.f90 b/flang/test/Lower/Intrinsics/math-runtime-options.f90
index e9daf26051d5d..4b48c9bc5719b 100644
--- a/flang/test/Lower/Intrinsics/math-runtime-options.f90
+++ b/flang/test/Lower/Intrinsics/math-runtime-options.f90
@@ -4,8 +4,6 @@
 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="FIR,RELAXED"
 ! RUN: bbc -emit-fir --math-runtime=precise -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="FIR,PRECISE"
 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="FIR,PRECISE"
-! RUN: bbc -emit-fir --math-runtime=llvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="FIR,LLVM"
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=llvm -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="FIR,LLVM"
 
 ! CHECK-LABEL: cos_testr
 subroutine cos_testr(a, b)
@@ -22,12 +20,10 @@ subroutine cos_testd(a, b)
 end subroutine
 
 ! FIR: @fir.cos.f32.f32(%arg0: f32) -> f32 attributes
-! FAST: fir.call @__fs_cos_1(%arg0) : (f32) -> f32
-! RELAXED: fir.call @__rs_cos_1(%arg0) : (f32) -> f32
-! PRECISE: fir.call @__ps_cos_1(%arg0) : (f32) -> f32
-! LLVM: fir.call @llvm.cos.f32(%arg0) : (f32) -> f32
+! FAST: math.cos %arg0 : f32
+! RELAXED: math.cos %arg0 : f32
+! PRECISE: fir.call @cosf(%arg0) : (f32) -> f32
 ! FIR: @fir.cos.f64.f64(%arg0: f64) -> f64
-! FAST: fir.call @__fd_cos_1(%arg0) : (f64) -> f64
-! RELAXED: fir.call @__rd_cos_1(%arg0) : (f64) -> f64
-! PRECISE: fir.call @__pd_cos_1(%arg0) : (f64) -> f64
-! LLVM: fir.call @llvm.cos.f64(%arg0) : (f64) -> f64
+! FAST: math.cos %arg0 : f64
+! RELAXED: math.cos %arg0 : f64
+! PRECISE: fir.call @cos(%arg0) : (f64) -> f64

diff  --git a/flang/test/Lower/Intrinsics/sign.f90 b/flang/test/Lower/Intrinsics/sign.f90
index fe24a23e867c6..218080f0d49b6 100644
--- a/flang/test/Lower/Intrinsics/sign.f90
+++ b/flang/test/Lower/Intrinsics/sign.f90
@@ -16,7 +16,7 @@ subroutine sign_testi(a, b, c)
 subroutine sign_testr(a, b, c)
   real a, b, c
   ! CHECK-NOT: fir.call @{{.*}}fabs
-  ! CHECK: fir.call @{{.*}}copysign{{.*}} : (f32, f32) -> f32
+  ! CHECK: math.copysign{{.*}} : f32
   c = sign(a, b)
 end subroutine
 
@@ -24,6 +24,6 @@ subroutine sign_testr(a, b, c)
 subroutine sign_testr2(a, b, c)
   real(KIND=16) a, b, c
   ! CHECK-NOT: fir.call @{{.*}}fabs
-  ! CHECK: fir.call @{{.*}}copysign{{.*}} : (f128, f128) -> f128
+  ! CHECK: math.copysign{{.*}} : f128
   c = sign(a, b)
 end subroutine

diff  --git a/flang/test/Lower/array-elemental-calls-2.f90 b/flang/test/Lower/array-elemental-calls-2.f90
index 0e3b37a6ae9b2..7ec7512e7efc8 100644
--- a/flang/test/Lower/array-elemental-calls-2.f90
+++ b/flang/test/Lower/array-elemental-calls-2.f90
@@ -135,7 +135,7 @@ subroutine check_pow()
 ! CHECK:  fir.do_loop
 ! CHECK:  %[[VAL_25:.*]] = fir.array_fetch %{{.*}}, %{{.*}} : (!fir.array<10xf64>, index) -> f64
 ! CHECK:  %[[VAL_26:.*]] = fir.array_fetch %{{.*}}, %{{.*}} : (!fir.array<10xf64>, index) -> f64
-! CHECK:  %[[VAL_27:.*]] = fir.call @__fd_pow_1(%[[VAL_25]], %[[VAL_26]]) : (f64, f64) -> f64
+! CHECK:  %[[VAL_27:.*]] = math.powf %[[VAL_25]], %[[VAL_26]] : f64
 ! CHECK:  fir.store %[[VAL_27]] to %[[VAL_0]] : !fir.ref<f64>
 ! CHECK:  %[[VAL_28:.*]] = fir.call @_QPelem_func_real(%[[VAL_0]]) : (!fir.ref<f64>) -> i32
 end subroutine

diff  --git a/flang/test/Lower/array-expression.f90 b/flang/test/Lower/array-expression.f90
index 3c4c8481ff661..953fd3ad72fe0 100644
--- a/flang/test/Lower/array-expression.f90
+++ b/flang/test/Lower/array-expression.f90
@@ -471,7 +471,7 @@ subroutine test15(a,b)
   real :: a(100), b(100)
   ! CHECK: %[[loop:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[bth:.*]] = %[[barr]]) -> (!fir.array<100xf32>) {
   ! CHECK: %[[val:.*]] = fir.array_fetch %[[aarr]], %[[i]] : (!fir.array<100xf32>, index) -> f32
-  ! CHECK: %[[fres:.*]] = fir.call @llvm.fabs.f32(%[[val]]) : (f32) -> f32
+  ! CHECK: %[[fres:.*]] = math.abs %[[val]] : f32
   ! CHECK: %[[res:.*]] = fir.array_update %[[bth]], %[[fres]], %[[i]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
   ! CHECK: fir.result %[[res]] : !fir.array<100xf32>
   ! CHECK: fir.array_merge_store %[[barr]], %[[loop]] to %[[b]]

diff  --git a/flang/test/Lower/dummy-procedure.f90 b/flang/test/Lower/dummy-procedure.f90
index 7e3ebddd19bec..1ad53cf35b2a7 100644
--- a/flang/test/Lower/dummy-procedure.f90
+++ b/flang/test/Lower/dummy-procedure.f90
@@ -161,7 +161,7 @@ subroutine todo3(dummy_proc)
 ! CHECK-SAME: %[[x:.*]]: !fir.ref<f32>, %[[y:.*]]: !fir.ref<f32>) -> f32
   ! CHECK-DAG: %[[xload:.*]] = fir.load %[[x]] : !fir.ref<f32>
   ! CHECK-DAG: %[[yload:.*]] = fir.load %[[y]] : !fir.ref<f32>
-  ! CHECK: %[[atan2:.*]] = fir.call @__fs_atan2_1(%[[xload]], %[[yload]]) : (f32, f32) -> f32
+  ! CHECK: %[[atan2:.*]] = math.atan2 %[[xload]], %[[yload]] : f32
   ! CHECK: return %[[atan2]] : f32
 
 !CHECK-LABEL: func private @fir.aimag.f32.ref_z4(%arg0: !fir.ref<!fir.complex<4>>)

diff  --git a/flang/test/Lower/late-math-lowering.f90 b/flang/test/Lower/late-math-lowering.f90
deleted file mode 100644
index f4b96f84479d1..0000000000000
--- a/flang/test/Lower/late-math-lowering.f90
+++ /dev/null
@@ -1,602 +0,0 @@
-! RUN: split-file %s %t
-
-//--- abs.f90
-! RUN: bbc -emit-fir %t/abs.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/abs.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/abs.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/abs.f90
-! RUN: bbc -emit-fir %t/abs.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/abs.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/abs.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/abs.f90
-! RUN: bbc -emit-fir %t/abs.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/abs.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/abs.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/abs.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = abs(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @fabsf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = abs(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @fabs({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-function test_real16(x)
-  real(16) :: x, test_real16
-  test_real16 = abs(x)
-end function
-! ALL-LABEL: @_QPtest_real16
-! FAST: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f128
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f128
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.fabs.f128({{%[A-Za-z0-9._]+}}) : (f128) -> f128
-
-function test_complex4(c)
-  complex(4) :: c, test_complex4
-  test_complex4 = abs(c)
-end function
-
-! ALL-LABEL: @_QPtest_complex4
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @hypotf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
-
-function test_complex8(c)
-  complex(8) :: c, test_complex8
-  test_complex8 = abs(c)
-end function
-
-! ALL-LABEL: @_QPtest_complex8
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @hypot({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
-
-//--- aint.f90
-! RUN: bbc -emit-fir %t/aint.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL %t/aint.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/aint.f90 -o - | FileCheck --check-prefixes=ALL %t/aint.f90
-! RUN: bbc -emit-fir %t/aint.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/aint.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/aint.f90 -o - | FileCheck --check-prefixes=ALL %t/aint.f90
-! RUN: bbc -emit-fir %t/aint.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL %t/aint.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/aint.f90 -o - | FileCheck --check-prefixes=ALL %t/aint.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = aint(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.trunc.f32({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = aint(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.trunc.f64({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- anint.f90
-! RUN: bbc -emit-fir %t/anint.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/anint.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/anint.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/anint.f90
-! RUN: bbc -emit-fir %t/anint.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/anint.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/anint.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/anint.f90
-! RUN: bbc -emit-fir %t/anint.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/anint.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/anint.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/anint.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = anint(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f32({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = anint(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f64({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- atan.f90
-! RUN: bbc -emit-fir %t/atan.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/atan.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/atan.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/atan.f90
-! RUN: bbc -emit-fir %t/atan.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/atan.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/atan.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/atan.f90
-! RUN: bbc -emit-fir %t/atan.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/atan.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/atan.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/atan.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = atan(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atanf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = atan(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atan({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- atan2.f90
-! RUN: bbc -emit-fir %t/atan2.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/atan2.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/atan2.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/atan2.f90
-! RUN: bbc -emit-fir %t/atan2.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/atan2.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/atan2.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/atan2.f90
-! RUN: bbc -emit-fir %t/atan2.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/atan2.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/atan2.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/atan2.f90
-
-function test_real4(x, y)
-  real :: x, y, test_real4
-  test_real4 = atan2(x, y)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atan2f({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
-
-function test_real8(x, y)
-  real(8) :: x, y, test_real8
-  test_real8 = atan2(x, y)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atan2({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
-
-//--- ceiling.f90
-! RUN: bbc -emit-fir %t/ceiling.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/ceiling.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/ceiling.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/ceiling.f90
-! RUN: bbc -emit-fir %t/ceiling.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/ceiling.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/ceiling.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/ceiling.f90
-! RUN: bbc -emit-fir %t/ceiling.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/ceiling.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/ceiling.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/ceiling.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = ceiling(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @ceilf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = ceiling(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @ceil({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- cos.f90
-! RUN: bbc -emit-fir %t/cos.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/cos.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/cos.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/cos.f90
-! RUN: bbc -emit-fir %t/cos.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/cos.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/cos.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/cos.f90
-! RUN: bbc -emit-fir %t/cos.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/cos.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/cos.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/cos.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = cos(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @cosf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = cos(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @cos({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- cosh.f90
-! RUN: bbc -emit-fir %t/cosh.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL %t/cosh.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
-! RUN: bbc -emit-fir %t/cosh.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/cosh.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
-! RUN: bbc -emit-fir %t/cosh.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL %t/cosh.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = cosh(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @coshf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = cosh(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cosh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- erf.f90
-! RUN: bbc -emit-fir %t/erf.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/erf.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/erf.f90
-! RUN: bbc -emit-fir %t/erf.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/erf.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/erf.f90
-! RUN: bbc -emit-fir %t/erf.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/erf.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/erf.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = erf(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @erff({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = erf(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @erf({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- exp.f90
-! RUN: bbc -emit-fir %t/exp.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/exp.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/exp.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/exp.f90
-! RUN: bbc -emit-fir %t/exp.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/exp.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/exp.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/exp.f90
-! RUN: bbc -emit-fir %t/exp.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/exp.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/exp.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/exp.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = exp(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @expf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = exp(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @exp({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- floor.f90
-! RUN: bbc -emit-fir %t/floor.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/floor.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/floor.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/floor.f90
-! RUN: bbc -emit-fir %t/floor.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/floor.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/floor.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/floor.f90
-! RUN: bbc -emit-fir %t/floor.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/floor.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/floor.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/floor.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = floor(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @floorf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = floor(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @floor({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- log.f90
-! RUN: bbc -emit-fir %t/log.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/log.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/log.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/log.f90
-! RUN: bbc -emit-fir %t/log.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/log.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/log.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/log.f90
-! RUN: bbc -emit-fir %t/log.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/log.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/log.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/log.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = log(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @logf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = log(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @log({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- log10.f90
-! RUN: bbc -emit-fir %t/log10.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/log10.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/log10.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/log10.f90
-! RUN: bbc -emit-fir %t/log10.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/log10.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/log10.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/log10.f90
-! RUN: bbc -emit-fir %t/log10.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/log10.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/log10.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/log10.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = log10(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @log10f({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = log10(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @log10({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- nint.f90
-! RUN: bbc -emit-fir %t/nint.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL %t/nint.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/nint.f90 -o - | FileCheck --check-prefixes=ALL %t/nint.f90
-! RUN: bbc -emit-fir %t/nint.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/nint.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/nint.f90 -o - | FileCheck --check-prefixes=ALL %t/nint.f90
-! RUN: bbc -emit-fir %t/nint.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL %t/nint.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/nint.f90 -o - | FileCheck --check-prefixes=ALL %t/nint.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = nint(x, 4) + nint(x, 8)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i32.f32({{%[A-Za-z0-9._]+}}) : (f32) -> i32
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i64.f32({{%[A-Za-z0-9._]+}}) : (f32) -> i64
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = nint(x, 4) + nint(x, 8)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i32.f64({{%[A-Za-z0-9._]+}}) : (f64) -> i32
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i64.f64({{%[A-Za-z0-9._]+}}) : (f64) -> i64
-
-//--- exponentiation.f90
-! RUN: bbc -emit-fir %t/exponentiation.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/exponentiation.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/exponentiation.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/exponentiation.f90
-! RUN: bbc -emit-fir %t/exponentiation.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/exponentiation.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/exponentiation.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/exponentiation.f90
-! RUN: bbc -emit-fir %t/exponentiation.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/exponentiation.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/exponentiation.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/exponentiation.f90
-
-function test_real4(x, y, s, i)
-  real :: x, y, test_real4
-  integer(2) :: s
-  integer(4) :: i
-  test_real4 = x ** s + x ** y + x ** i
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! ALL: [[STOI:%[A-Za-z0-9._]+]] = fir.convert {{%[A-Za-z0-9._]+}} : (i16) -> i32
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.powi.f32.i32({{%[A-Za-z0-9._]+}}, [[STOI]]) : (f32, i32) -> f32
-! FAST: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @powf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.powi.f32.i32({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, i32) -> f32
-
-function test_real8(x, y, s, i)
-  real(8) :: x, y, test_real8
-  integer(2) :: s
-  integer(4) :: i
-  test_real8 = x ** s + x ** y + x ** i
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! ALL: [[STOI:%[A-Za-z0-9._]+]] = fir.convert {{%[A-Za-z0-9._]+}} : (i16) -> i32
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.powi.f64.i32({{%[A-Za-z0-9._]+}}, [[STOI]]) : (f64, i32) -> f64
-! FAST: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @pow({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.powi.f64.i32({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, i32) -> f64
-
-//--- sign.f90
-! RUN: bbc -emit-fir %t/sign.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/sign.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/sign.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/sign.f90
-! RUN: bbc -emit-fir %t/sign.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/sign.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/sign.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/sign.f90
-! RUN: bbc -emit-fir %t/sign.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/sign.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/sign.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/sign.f90
-
-function test_real4(x, y)
-  real :: x, y, test_real4
-  test_real4 = sign(x, y)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysignf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
-
-function test_real8(x, y)
-  real(8) :: x, y, test_real8
-  test_real8 = sign(x, y)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysign({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
-
-function test_real10(x, y)
-  real(10) :: x, y, test_real10
-  test_real10 = sign(x, y)
-end function
-
-! ALL-LABEL: @_QPtest_real10
-! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f80
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f80
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysignl({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f80, f80) -> f80
-
-function test_real16(x, y)
-  real(16) :: x, y, test_real16
-  test_real16 = sign(x, y)
-end function
-
-! ALL-LABEL: @_QPtest_real16
-! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f128
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f128
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.copysign.f128({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f128, f128) -> f128
-
-//--- sin.f90
-! RUN: bbc -emit-fir %t/sin.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/sin.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/sin.f90
-! RUN: bbc -emit-fir %t/sin.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/sin.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/sin.f90
-! RUN: bbc -emit-fir %t/sin.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/sin.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/sin.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = sin(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @sinf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = sin(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @sin({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- sinh.f90
-! RUN: bbc -emit-fir %t/sinh.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL %t/sinh.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
-! RUN: bbc -emit-fir %t/sinh.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/sinh.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
-! RUN: bbc -emit-fir %t/sinh.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL %t/sinh.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = sinh(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @sinhf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = sinh(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @sinh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- tanh.f90
-! RUN: bbc -emit-fir %t/tanh.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/tanh.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/tanh.f90
-! RUN: bbc -emit-fir %t/tanh.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/tanh.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/tanh.f90
-! RUN: bbc -emit-fir %t/tanh.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/tanh.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/tanh.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = tanh(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanhf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = tanh(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
-
-//--- tan.f90
-! RUN: bbc -emit-fir %t/tan.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/tan.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/tan.f90
-! RUN: bbc -emit-fir %t/tan.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/tan.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/tan.f90
-! RUN: bbc -emit-fir %t/tan.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/tan.f90
-! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/tan.f90
-
-function test_real4(x)
-  real :: x, test_real4
-  test_real4 = tan(x)
-end function
-
-! ALL-LABEL: @_QPtest_real4
-! FAST: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f32
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f32
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
-
-function test_real8(x)
-  real(8) :: x, test_real8
-  test_real8 = tan(x)
-end function
-
-! ALL-LABEL: @_QPtest_real8
-! FAST: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f64
-! RELAXED: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f64
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tan({{%[A-Za-z0-9._]+}}) : (f64) -> f64

diff  --git a/flang/test/Lower/llvm-math.f90 b/flang/test/Lower/llvm-math.f90
deleted file mode 100644
index 8ad4809bb8228..0000000000000
--- a/flang/test/Lower/llvm-math.f90
+++ /dev/null
@@ -1,219 +0,0 @@
-! RUN: bbc -emit-fir %s -o - --math-runtime=llvm --outline-intrinsics | FileCheck %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=llvm -mllvm -outline-intrinsics %s -o - | FileCheck %s
-
-      SUBROUTINE POW_WRAPPER(IN, IN2, OUT)
-      DOUBLE PRECISION IN, IN2
-      OUT = IN ** IN2
-      RETURN
-      END
-      
-! CHECK-LABEL: func @_QPpow_wrapper(
-! CHECK-SAME: %{{.*}}: !fir.ref<f64>{{.*}}, %{{.*}}: !fir.ref<f64>{{.*}}, %{{.*}}: !fir.ref<f32>{{.*}}) {
-! CHECK-NEXT:   %0 = fir.load %arg0 : !fir.ref<f64>
-! CHECK-NEXT:   %1 = fir.load %arg1 : !fir.ref<f64>
-! CHECK-NEXT:   %2 = fir.call @llvm.pow.f64(%0, %1) : (f64, f64) -> f64
-
-      SUBROUTINE POWF_WRAPPER(IN, IN2, OUT)
-      REAL IN, IN2
-      OUT = IN ** IN2
-      RETURN
-      END
-
-! CHECK-LABEL: func @_QPpowf_wrapper(
-! CHECK-SAME: %{{.*}}: !fir.ref<f32>{{.*}}, %{{.*}}: !fir.ref<f32>{{.*}}, %{{.*}}: !fir.ref<f32>{{.*}}) {
-! CHECK-NEXT:   %0 = fir.load %arg0 : !fir.ref<f32>
-! CHECK-NEXT:   %1 = fir.load %arg1 : !fir.ref<f32>
-! CHECK-NEXT:   %2 = fir.call @llvm.pow.f32(%0, %1) : (f32, f32) -> f32
-
-      SUBROUTINE ATAN_WRAPPER(IN, OUT)
-      DOUBLE PRECISION IN
-      OUT = DATAN(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.atan.f64.f64(%arg0: f64)
-! CHECK-NEXT:   %0 = fir.call @atan(%arg0) : (f64) -> f64
-! CHECK-NEXT:   return %0 : f64
-! CHECK-NEXT: }
-
-      SUBROUTINE EXP_WRAPPER(IN, OUT)
-      DOUBLE PRECISION IN
-      OUT = DEXP(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.exp.f64.f64(%arg0: f64)
-! CHECK-NEXT:   %0 = fir.call @llvm.exp.f64(%arg0) : (f64) -> f64
-! CHECK-NEXT:   return %0 : f64
-! CHECK-NEXT: }
-
-      SUBROUTINE SINH_WRAPPER(IN, OUT)
-      DOUBLE PRECISION IN
-      OUT = DSINH(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.sinh.f64.f64(%arg0: f64)
-! CHECK-NEXT:   %0 = fir.call @sinh(%arg0) : (f64) -> f64
-! CHECK-NEXT:   return %0 : f64
-! CHECK-NEXT: }
-
-      SUBROUTINE COSH_WRAPPER(IN, OUT)
-      DOUBLE PRECISION IN
-      OUT = DCOSH(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.cosh.f64.f64(%arg0: f64)
-! CHECK-NEXT:   %0 = fir.call @cosh(%arg0) : (f64) -> f64
-! CHECK-NEXT:   return %0 : f64
-! CHECK-NEXT: }
-
-
-      SUBROUTINE ATANF_WRAPPER(IN, OUT)
-      REAL IN
-      OUT = ATAN(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.atan.f32.f32(%arg0: f32)
-! CHECK-NEXT:   %0 = fir.call @atanf(%arg0) : (f32) -> f32
-! CHECK-NEXT:   return %0 : f32
-! CHECK-NEXT: }
-
-      SUBROUTINE EXPF_WRAPPER(IN, OUT)
-      REAL IN
-      OUT = EXP(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.exp.f32.f32(%arg0: f32)
-! CHECK-NEXT:   %0 = fir.call @llvm.exp.f32(%arg0) : (f32) -> f32
-! CHECK-NEXT:   return %0 : f32
-! CHECK-NEXT: }
-
-      SUBROUTINE SINHF_WRAPPER(IN, OUT)
-      REAL IN
-      OUT = SINH(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.sinh.f32.f32(%arg0: f32)
-! CHECK-NEXT:   %0 = fir.call @sinhf(%arg0) : (f32) -> f32
-! CHECK-NEXT:   return %0 : f32
-! CHECK-NEXT: }
-
-      SUBROUTINE COSHF_WRAPPER(IN, OUT)
-      REAL IN
-      OUT = COSH(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.cosh.f32.f32(%arg0: f32)
-! CHECK-NEXT:   %0 = fir.call @coshf(%arg0) : (f32) -> f32
-! CHECK-NEXT:   return %0 : f32
-! CHECK-NEXT: }
-
-      SUBROUTINE LOG_WRAPPER(IN, OUT)
-      DOUBLE PRECISION IN, OUT
-      OUT = DLOG(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.log.f64.f64(%arg0: f64)
-! CHECK-NEXT:   %0 = fir.call @llvm.log.f64(%arg0) : (f64) -> f64
-! CHECK-NEXT:   return %0 : f64
-! CHECK-NEXT: }
-
-      SUBROUTINE LOG10_WRAPPER(IN, OUT)
-      DOUBLE PRECISION IN, OUT
-      OUT = DLOG10(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.log10.f64.f64(%arg0: f64)
-! CHECK-NEXT:   %0 = fir.call @llvm.log10.f64(%arg0) : (f64) -> f64
-! CHECK-NEXT:   return %0 : f64
-! CHECK-NEXT: }
-
-      SUBROUTINE LOGF_WRAPPER(IN, OUT)
-      REAL IN, OUT
-      OUT = LOG(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.log.f32.f32(%arg0: f32)
-! CHECK-NEXT:   %0 = fir.call @llvm.log.f32(%arg0) : (f32) -> f32
-! CHECK-NEXT:   return %0 : f32
-! CHECK-NEXT: }
-
-      SUBROUTINE LOG10F_WRAPPER(IN, OUT)
-      REAL IN, OUT
-      OUT = LOG10(IN)
-      RETURN
-      END
-
-! CHECK:       func private @fir.log10.f32.f32(%arg0: f32)
-! CHECK-NEXT:   %0 = fir.call @llvm.log10.f32(%arg0) : (f32) -> f32
-! CHECK-NEXT:   return %0 : f32
-! CHECK-NEXT: }
-
-      SUBROUTINE SQRT_WRAPPER(IN, OUT)
-      REAL :: IN, OUT
-      OUT = SQRT(IN)
-      END SUBROUTINE
-
-! CHECK-LABEL: func private @fir.sqrt.f32.f32(%arg0: f32)
-! CHECK-NEXT:  %0 = fir.call @llvm.sqrt.f32(%arg0) : (f32) -> f32
-! CHECK-NEXT:   return %0 : f32
-! CHECK-NEXT: }
-
-      SUBROUTINE SQRTD_WRAPPER(IN, OUT)
-      REAL(KIND=8) :: IN, OUT
-      OUT = SQRT(IN)
-      END SUBROUTINE
-
-! CHECK-LABEL: func private @fir.sqrt.f64.f64(%arg0: f64)
-! CHECK-NEXT:  %0 = fir.call @llvm.sqrt.f64(%arg0) : (f64) -> f64
-! CHECK-NEXT:   return %0 : f64
-! CHECK-NEXT: }
-
-      SUBROUTINE COS_WRAPPER(IN, OUT)
-      REAL :: IN, OUT
-      OUT = COS(IN)
-      END SUBROUTINE
-
-! CHECK-LABEL: func private @fir.cos.f32.f32(%arg0: f32)
-! CHECK-NEXT:  %0 = fir.call @llvm.cos.f32(%arg0) : (f32) -> f32
-! CHECK-NEXT:   return %0 : f32
-! CHECK-NEXT: }
-
-      SUBROUTINE COSD_WRAPPER(IN, OUT)
-      REAL(KIND=8) :: IN, OUT
-      OUT = COS(IN)
-      END SUBROUTINE
-
-! CHECK-LABEL: func private @fir.cos.f64.f64(%arg0: f64)
-! CHECK-NEXT:  %0 = fir.call @llvm.cos.f64(%arg0) : (f64) -> f64
-! CHECK-NEXT:   return %0 : f64
-! CHECK-NEXT: }
-
-      SUBROUTINE SIN_WRAPPER(IN, OUT)
-      REAL :: IN, OUT
-      OUT = SIN(IN)
-      END SUBROUTINE
-
-! CHECK-LABEL: func private @fir.sin.f32.f32(%arg0: f32)
-! CHECK-NEXT:  %0 = fir.call @llvm.sin.f32(%arg0) : (f32) -> f32
-! CHECK-NEXT:   return %0 : f32
-! CHECK-NEXT: }
-
-      SUBROUTINE SIND_WRAPPER(IN, OUT)
-      REAL(KIND=8) :: IN, OUT
-      OUT = SIN(IN)
-      END SUBROUTINE
-
-! CHECK-LABEL: func private @fir.sin.f64.f64(%arg0: f64)
-! CHECK-NEXT:  %0 = fir.call @llvm.sin.f64(%arg0) : (f64) -> f64
-! CHECK-NEXT:   return %0 : f64
-! CHECK-NEXT: }

diff  --git a/flang/test/Lower/math-lowering.f90 b/flang/test/Lower/math-lowering.f90
new file mode 100644
index 0000000000000..4eb9b97a93082
--- /dev/null
+++ b/flang/test/Lower/math-lowering.f90
@@ -0,0 +1,602 @@
+! RUN: split-file %s %t
+
+//--- abs.f90
+! RUN: bbc -emit-fir %t/abs.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/abs.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/abs.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/abs.f90
+! RUN: bbc -emit-fir %t/abs.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/abs.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/abs.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/abs.f90
+! RUN: bbc -emit-fir %t/abs.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/abs.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/abs.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/abs.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = abs(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @fabsf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = abs(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @fabs({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+function test_real16(x)
+  real(16) :: x, test_real16
+  test_real16 = abs(x)
+end function
+! ALL-LABEL: @_QPtest_real16
+! FAST: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f128
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f128
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.fabs.f128({{%[A-Za-z0-9._]+}}) : (f128) -> f128
+
+function test_complex4(c)
+  complex(4) :: c, test_complex4
+  test_complex4 = abs(c)
+end function
+
+! ALL-LABEL: @_QPtest_complex4
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @hypotf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
+
+function test_complex8(c)
+  complex(8) :: c, test_complex8
+  test_complex8 = abs(c)
+end function
+
+! ALL-LABEL: @_QPtest_complex8
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @hypot({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
+
+//--- aint.f90
+! RUN: bbc -emit-fir %t/aint.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %t/aint.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/aint.f90 -o - | FileCheck --check-prefixes=ALL %t/aint.f90
+! RUN: bbc -emit-fir %t/aint.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/aint.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/aint.f90 -o - | FileCheck --check-prefixes=ALL %t/aint.f90
+! RUN: bbc -emit-fir %t/aint.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %t/aint.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/aint.f90 -o - | FileCheck --check-prefixes=ALL %t/aint.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = aint(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.trunc.f32({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = aint(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.trunc.f64({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- anint.f90
+! RUN: bbc -emit-fir %t/anint.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/anint.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/anint.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/anint.f90
+! RUN: bbc -emit-fir %t/anint.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/anint.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/anint.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/anint.f90
+! RUN: bbc -emit-fir %t/anint.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/anint.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/anint.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/anint.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = anint(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f32({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = anint(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f64({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- atan.f90
+! RUN: bbc -emit-fir %t/atan.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/atan.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/atan.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/atan.f90
+! RUN: bbc -emit-fir %t/atan.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/atan.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/atan.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/atan.f90
+! RUN: bbc -emit-fir %t/atan.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/atan.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/atan.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/atan.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = atan(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atanf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = atan(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atan({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- atan2.f90
+! RUN: bbc -emit-fir %t/atan2.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/atan2.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/atan2.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/atan2.f90
+! RUN: bbc -emit-fir %t/atan2.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/atan2.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/atan2.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/atan2.f90
+! RUN: bbc -emit-fir %t/atan2.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/atan2.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/atan2.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/atan2.f90
+
+function test_real4(x, y)
+  real :: x, y, test_real4
+  test_real4 = atan2(x, y)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atan2f({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
+
+function test_real8(x, y)
+  real(8) :: x, y, test_real8
+  test_real8 = atan2(x, y)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atan2({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
+
+//--- ceiling.f90
+! RUN: bbc -emit-fir %t/ceiling.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/ceiling.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/ceiling.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/ceiling.f90
+! RUN: bbc -emit-fir %t/ceiling.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/ceiling.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/ceiling.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/ceiling.f90
+! RUN: bbc -emit-fir %t/ceiling.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/ceiling.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/ceiling.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/ceiling.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = ceiling(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @ceilf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = ceiling(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @ceil({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- cos.f90
+! RUN: bbc -emit-fir %t/cos.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/cos.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/cos.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/cos.f90
+! RUN: bbc -emit-fir %t/cos.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/cos.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/cos.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/cos.f90
+! RUN: bbc -emit-fir %t/cos.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/cos.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/cos.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/cos.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = cos(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @cosf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = cos(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @cos({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- cosh.f90
+! RUN: bbc -emit-fir %t/cosh.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: bbc -emit-fir %t/cosh.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: bbc -emit-fir %t/cosh.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = cosh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @coshf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = cosh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cosh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- erf.f90
+! RUN: bbc -emit-fir %t/erf.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/erf.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/erf.f90
+! RUN: bbc -emit-fir %t/erf.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/erf.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/erf.f90
+! RUN: bbc -emit-fir %t/erf.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/erf.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/erf.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = erf(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @erff({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = erf(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @erf({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- exp.f90
+! RUN: bbc -emit-fir %t/exp.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/exp.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/exp.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/exp.f90
+! RUN: bbc -emit-fir %t/exp.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/exp.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/exp.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/exp.f90
+! RUN: bbc -emit-fir %t/exp.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/exp.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/exp.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/exp.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = exp(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @expf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = exp(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @exp({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- floor.f90
+! RUN: bbc -emit-fir %t/floor.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/floor.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/floor.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/floor.f90
+! RUN: bbc -emit-fir %t/floor.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/floor.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/floor.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/floor.f90
+! RUN: bbc -emit-fir %t/floor.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/floor.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/floor.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/floor.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = floor(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @floorf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = floor(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @floor({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- log.f90
+! RUN: bbc -emit-fir %t/log.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/log.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/log.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/log.f90
+! RUN: bbc -emit-fir %t/log.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/log.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/log.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/log.f90
+! RUN: bbc -emit-fir %t/log.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/log.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/log.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/log.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = log(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @logf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = log(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @log({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- log10.f90
+! RUN: bbc -emit-fir %t/log10.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/log10.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/log10.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/log10.f90
+! RUN: bbc -emit-fir %t/log10.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/log10.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/log10.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/log10.f90
+! RUN: bbc -emit-fir %t/log10.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/log10.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/log10.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/log10.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = log10(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @log10f({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = log10(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @log10({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- nint.f90
+! RUN: bbc -emit-fir %t/nint.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %t/nint.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/nint.f90 -o - | FileCheck --check-prefixes=ALL %t/nint.f90
+! RUN: bbc -emit-fir %t/nint.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/nint.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/nint.f90 -o - | FileCheck --check-prefixes=ALL %t/nint.f90
+! RUN: bbc -emit-fir %t/nint.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %t/nint.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/nint.f90 -o - | FileCheck --check-prefixes=ALL %t/nint.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = nint(x, 4) + nint(x, 8)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i32.f32({{%[A-Za-z0-9._]+}}) : (f32) -> i32
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i64.f32({{%[A-Za-z0-9._]+}}) : (f32) -> i64
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = nint(x, 4) + nint(x, 8)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i32.f64({{%[A-Za-z0-9._]+}}) : (f64) -> i32
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i64.f64({{%[A-Za-z0-9._]+}}) : (f64) -> i64
+
+//--- exponentiation.f90
+! RUN: bbc -emit-fir %t/exponentiation.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/exponentiation.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/exponentiation.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/exponentiation.f90
+! RUN: bbc -emit-fir %t/exponentiation.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/exponentiation.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/exponentiation.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/exponentiation.f90
+! RUN: bbc -emit-fir %t/exponentiation.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/exponentiation.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/exponentiation.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/exponentiation.f90
+
+function test_real4(x, y, s, i)
+  real :: x, y, test_real4
+  integer(2) :: s
+  integer(4) :: i
+  test_real4 = x ** s + x ** y + x ** i
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! ALL: [[STOI:%[A-Za-z0-9._]+]] = fir.convert {{%[A-Za-z0-9._]+}} : (i16) -> i32
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.powi.f32.i32({{%[A-Za-z0-9._]+}}, [[STOI]]) : (f32, i32) -> f32
+! FAST: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @powf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.powi.f32.i32({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, i32) -> f32
+
+function test_real8(x, y, s, i)
+  real(8) :: x, y, test_real8
+  integer(2) :: s
+  integer(4) :: i
+  test_real8 = x ** s + x ** y + x ** i
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! ALL: [[STOI:%[A-Za-z0-9._]+]] = fir.convert {{%[A-Za-z0-9._]+}} : (i16) -> i32
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.powi.f64.i32({{%[A-Za-z0-9._]+}}, [[STOI]]) : (f64, i32) -> f64
+! FAST: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @pow({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.powi.f64.i32({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, i32) -> f64
+
+//--- sign.f90
+! RUN: bbc -emit-fir %t/sign.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/sign.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/sign.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/sign.f90
+! RUN: bbc -emit-fir %t/sign.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/sign.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/sign.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/sign.f90
+! RUN: bbc -emit-fir %t/sign.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/sign.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/sign.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/sign.f90
+
+function test_real4(x, y)
+  real :: x, y, test_real4
+  test_real4 = sign(x, y)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysignf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
+
+function test_real8(x, y)
+  real(8) :: x, y, test_real8
+  test_real8 = sign(x, y)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysign({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
+
+function test_real10(x, y)
+  real(10) :: x, y, test_real10
+  test_real10 = sign(x, y)
+end function
+
+! ALL-LABEL: @_QPtest_real10
+! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f80
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f80
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysignl({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f80, f80) -> f80
+
+function test_real16(x, y)
+  real(16) :: x, y, test_real16
+  test_real16 = sign(x, y)
+end function
+
+! ALL-LABEL: @_QPtest_real16
+! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f128
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f128
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.copysign.f128({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f128, f128) -> f128
+
+//--- sin.f90
+! RUN: bbc -emit-fir %t/sin.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/sin.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/sin.f90
+! RUN: bbc -emit-fir %t/sin.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/sin.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/sin.f90
+! RUN: bbc -emit-fir %t/sin.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/sin.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/sin.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = sin(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @sinf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = sin(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @sin({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- sinh.f90
+! RUN: bbc -emit-fir %t/sinh.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: bbc -emit-fir %t/sinh.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: bbc -emit-fir %t/sinh.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = sinh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @sinhf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = sinh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @sinh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- tanh.f90
+! RUN: bbc -emit-fir %t/tanh.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/tanh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/tanh.f90
+! RUN: bbc -emit-fir %t/tanh.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/tanh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/tanh.f90
+! RUN: bbc -emit-fir %t/tanh.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/tanh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/tanh.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = tanh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanhf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = tanh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- tan.f90
+! RUN: bbc -emit-fir %t/tan.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/tan.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/tan.f90
+! RUN: bbc -emit-fir %t/tan.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/tan.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/tan.f90
+! RUN: bbc -emit-fir %t/tan.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/tan.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/tan.f90
+
+function test_real4(x)
+  real :: x, test_real4
+  test_real4 = tan(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+  real(8) :: x, test_real8
+  test_real8 = tan(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tan({{%[A-Za-z0-9._]+}}) : (f64) -> f64

diff  --git a/flang/test/Lower/power-operator.f90 b/flang/test/Lower/power-operator.f90
index afde20e73e097..d5429352873df 100644
--- a/flang/test/Lower/power-operator.f90
+++ b/flang/test/Lower/power-operator.f90
@@ -7,14 +7,14 @@ subroutine pow_r4_i4(x, y, z)
   real :: x, z
   integer :: y
   z = x ** y
-  ! CHECK: call @__fs_powi_1
+  ! CHECK: call @llvm.powi.f32.i32
 end subroutine
 
 ! CHECK-LABEL: pow_r4_r4
 subroutine pow_r4_r4(x, y, z)
   real :: x, z, y
   z = x ** y
-  ! CHECK: call @__fs_pow_1
+  ! CHECK: math.powf %{{.*}}, %{{.*}} : f32
 end subroutine
 
 ! CHECK-LABEL: pow_r4_i8
@@ -30,7 +30,7 @@ subroutine pow_r8_i4(x, y, z)
   real(8) :: x, z
   integer :: y
   z = x ** y
-  ! CHECK: call @__fd_powi_1
+  ! CHECK: call @llvm.powi.f64.i32
 end subroutine
 
 ! CHECK-LABEL: pow_r8_i8
@@ -45,7 +45,7 @@ subroutine pow_r8_i8(x, y, z)
 subroutine pow_r8_r8(x, y, z)
   real(8) :: x, z, y
   z = x ** y
-  ! CHECK: call @__fd_pow_1
+  ! CHECK: math.powf %{{.*}}, %{{.*}} : f64
 end subroutine
 
 ! CHECK-LABEL: pow_r4_r8
@@ -54,7 +54,7 @@ subroutine pow_r4_r8(x, y, z)
   real(8) :: z, y
   z = x ** y
   ! CHECK: %{{.*}} = fir.convert %{{.*}} : (f32) -> f64
-  ! CHECK: call @__fd_pow_1
+  ! CHECK: math.powf %{{.*}}, %{{.*}} : f64
 end subroutine
 
 ! CHECK-LABEL: pow_i4_i4

diff  --git a/flang/test/Lower/sqrt.f90 b/flang/test/Lower/sqrt.f90
index d0f13dff1fffe..af48387e718f0 100644
--- a/flang/test/Lower/sqrt.f90
+++ b/flang/test/Lower/sqrt.f90
@@ -30,10 +30,10 @@ subroutine sqrt_testcd(z)
 end subroutine
 
 ! CHECK-LABEL: @fir.sqrt.f32.f32
-! CHECK: fir.call {{.*}}mth_i_sqrt
+! CHECK: math.sqrt %{{.*}} : f32
 
 ! CHECK-LABEL: @fir.sqrt.f64.f64
-! CHECK: fir.call {{.*}}mth_i_dsqrt
+! CHECK: math.sqrt %{{.*}} : f64
 
 ! CHECK-LABEL: func private @fir.sqrt.z4.z4
 ! CHECK: fir.call {{.*}}fc_sqrt

diff  --git a/flang/test/Lower/trigonometric-intrinsics.f90 b/flang/test/Lower/trigonometric-intrinsics.f90
index e92d7f4ebd493..de8d88fd36f41 100644
--- a/flang/test/Lower/trigonometric-intrinsics.f90
+++ b/flang/test/Lower/trigonometric-intrinsics.f90
@@ -142,10 +142,10 @@ subroutine sinh_testcd(z)
 end subroutine
 
 ! CHECK-LABEL: @fir.atan.f32.f32
-! CHECK: fir.call {{.*}}atan
+! CHECK: math.atan %{{.*}} : f32
 
 ! CHECK-LABEL: @fir.atan.f64.f64
-! CHECK: fir.call {{.*}}atan
+! CHECK: math.atan %{{.*}} : f64
 
 ! CHECK-LABEL: @fir.atan.z4.z4
 ! CHECK: fir.call {{.*}}atan
@@ -154,10 +154,10 @@ subroutine sinh_testcd(z)
 ! CHECK: fir.call {{.*}}atan
 
 ! CHECK-LABEL: @fir.cos.f32.f32
-! CHECK: fir.call {{.*}}cos
+! CHECK: math.cos %{{.*}} : f32
 
 ! CHECK-LABEL: @fir.cos.f64.f64
-! CHECK: fir.call {{.*}}cos
+! CHECK: math.cos %{{.*}} : f64
 
 ! CHECK-LABEL: @fir.cos.z4.z4
 ! CHECK: fir.call {{.*}}cos
@@ -178,10 +178,10 @@ subroutine sinh_testcd(z)
 ! CHECK: fir.call {{.*}}cosh
 
 ! CHECK-LABEL: @fir.sin.f32.f32
-! CHECK: fir.call {{.*}}sin
+! CHECK: math.sin %{{.*}} : f32
 
 ! CHECK-LABEL: @fir.sin.f64.f64
-! CHECK: fir.call {{.*}}sin
+! CHECK: math.sin %{{.*}} : f64
 
 ! CHECK-LABEL: @fir.sin.z4.z4
 ! CHECK: fir.call {{.*}}sin


        


More information about the flang-commits mailing list