xref: /llvm-project/flang/test/Lower/Intrinsics/cosd.f90 (revision 2dd254566d0242be2d78f1656cee12a84e7aea00)
1! RUN: bbc -emit-fir %s -o - | FileCheck %s --check-prefixes="CHECK,CHECK-FAST"
2! RUN: bbc --math-runtime=precise -emit-fir %s -o - | FileCheck %s --check-prefixes="CHECK,CHECK-PRECISE"
3! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s --check-prefixes="CHECK,CHECK-FAST"
4
5function test_real4(x)
6  real :: x, test_real4
7  test_real4 = cosd(x)
8end function
9
10! CHECK-LABEL: @_QPtest_real4
11! CHECK: %[[dfactor:.*]] = arith.constant 0.017453292519943295 : f64
12! CHECK: %[[factor:.*]] = fir.convert %[[dfactor]] : (f64) -> f32
13! CHECK: %[[arg:.*]] = arith.mulf %{{[A-Za-z0-9._]+}}, %[[factor]] fastmath<contract> : f32
14! CHECK-PRECISE: %{{.*}} = fir.call @cosf(%[[arg]]) fastmath<contract> : (f32) -> f32
15! CHECK-FAST: %{{.*}} = math.cos %[[arg]] fastmath<contract> : f32
16
17function test_real8(x)
18  real(8) :: x, test_real8
19  test_real8 = cosd(x)
20end function
21
22! CHECK-LABEL: @_QPtest_real8
23! CHECK: %[[factor:.*]] = arith.constant 0.017453292519943295 : f64
24! CHECK: %[[arg:.*]] = arith.mulf %{{[A-Za-z0-9._]+}}, %[[factor]] fastmath<contract> : f64
25! CHECK-PRECISE: %{{.*}} = fir.call @cos(%[[arg]]) fastmath<contract> : (f64) -> f64
26! CHECK-FAST: %{{.*}} = math.cos %[[arg]] fastmath<contract> : f64
27