xref: /llvm-project/flang/test/Lower/Intrinsics/atanpi.f90 (revision 1d3d8936baf9f15e23603bbb1cfe0a5610d458d3)
1! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s --check-prefixes="CHECK,CHECK-FAST"
2! RUN: bbc --math-runtime=precise -emit-fir -hlfir=false %s -o - | FileCheck %s --check-prefixes="CHECK,CHECK-PRECISE"
3! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s --check-prefixes="CHECK,CHECK-FAST"
4
5function test_real4(x)
6  real :: x, test_real4
7  test_real4 = atanpi(x)
8end function
9
10! CHECK-LABEL: @_QPtest_real4
11! CHECK-PRECISE: %[[atan:.*]] = fir.call @atanf({{%[A-Za-z0-9._]+}}) fastmath<contract> : (f32) -> f32
12! CHECK-FAST: %[[atan:.*]] = math.atan %{{.*}} : f32
13! CHECK: %[[dpi:.*]] = arith.constant 0.31830988618379069 : f64
14! CHECK: %[[inv_pi:.*]] = fir.convert %[[dpi]] : (f64) -> f32
15! CHECK: %{{.*}} = arith.mulf %[[atan]], %[[inv_pi]] fastmath<contract> : f32
16
17function test_real8(x)
18  real(8) :: x, test_real8
19  test_real8 = atanpi(x)
20end function
21
22! CHECK-LABEL: @_QPtest_real8
23! CHECK-PRECISE: %[[atan:.*]] = fir.call @atan({{%[A-Za-z0-9._]+}}) fastmath<contract> : (f64) -> f64
24! CHECK-FAST: %[[atan:.*]] = math.atan %{{.*}} : f64
25! CHECK: %[[inv_pi:.*]] = arith.constant 0.31830988618379069 : f64
26! CHECK: %{{.*}} = arith.mulf %[[atan]], %[[inv_pi]] fastmath<contract> : f64
27
28function test_real4_yx(y,x)
29  real(4) :: x, y, test_real4
30  test_real4 = atanpi(y,x)
31end function
32
33! CHECK-LABEL: @_QPtest_real4_yx
34! CHECK: %[[atan2:.*]] = math.atan2 %{{.*}}, %{{.*}}: f32
35! CHECK: %[[dpi:.*]] = arith.constant 0.31830988618379069 : f64
36! CHECK: %[[inv_pi:.*]] = fir.convert %[[dpi]] : (f64) -> f32
37! CHECK: %{{.*}} = arith.mulf %[[atan2]], %[[inv_pi]] fastmath<contract> : f32
38
39function test_real8_yx(y,x)
40  real(8) :: x, y, test_real8
41  test_real8 = atanpi(y,x)
42end function
43
44! CHECK-LABEL: @_QPtest_real8_yx
45! CHECK: %[[atan2:.*]] = math.atan2 %{{.*}}, %{{.*}}: f64
46! CHECK: %[[inv_pi:.*]] = arith.constant 0.31830988618379069 : f64
47! CHECK: %{{.*}} = arith.mulf %[[atan2]], %[[inv_pi]] fastmath<contract> : f64
48