Revert "[InstCombine] Support gep nuw in icmp folds" (#118698)
[llvm-project.git] / flang / test / Lower / Intrinsics / log.f90
blob0e8d173fd8e0a21dd704f82a3214348d78c9d296
1 ! RUN: bbc -emit-fir -hlfir=false -outline-intrinsics %s -o - | FileCheck %s --check-prefixes=%if system-aix %{"CHECK,CMPLX,CMPLX-PRECISE,AIX-LOG"%} %else %{"CHECK,CMPLX,CMPLX-PRECISE,COMMON-LOG"%}
2 ! RUN: bbc -emit-fir -hlfir=false --math-runtime=precise -outline-intrinsics %s -o - | FileCheck %s --check-prefixes=%if system-aix %{"CMPLX,CMPLX-PRECISE,AIX-LOG"%} %else %{"CMPLX,CMPLX-PRECISE,COMMON-LOG"%}
3 ! RUN: bbc -emit-fir -hlfir=false --force-mlir-complex -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-FAST,CMPLX-MLIR"
4 ! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes=%if system-aix %{"CHECK,CMPLX,CMPLX-PRECISE,AIX-LOG"%} %else %{"CHECK,CMPLX,CMPLX-PRECISE,COMMON-LOG"%}
5 ! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics -mllvm --math-runtime=precise %s -o - | FileCheck %s --check-prefixes=%if system-aix %{"CMPLX,CMPLX-PRECISE,AIX-LOG"%} %else %{"CMPLX,CMPLX-PRECISE,COMMON-LOG"%}
6 ! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics -mllvm --force-mlir-complex %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-FAST,CMPLX-MLIR"
7 ! RUN: %flang_fc1 -fapprox-func -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-APPROX"
9 ! CHECK-LABEL: log_testr
10 ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref<f32> {{.*}}, %[[BREF:.*]]: !fir.ref<f32> {{.*}})
11 subroutine log_testr(a, b)
12 real :: a, b
13 ! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f32>
14 ! CHECK: %[[RES:.*]] = fir.call @fir.log.contract.f32.f32(%[[A]]) {{.*}}: (f32) -> f32
15 ! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f32>
16 b = log(a)
17 end subroutine
19 ! CHECK-LABEL: log_testd
20 ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref<f64> {{.*}}, %[[BREF:.*]]: !fir.ref<f64> {{.*}})
21 subroutine log_testd(a, b)
22 real(kind=8) :: a, b
23 ! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f64>
24 ! CHECK: %[[RES:.*]] = fir.call @fir.log.contract.f64.f64(%[[A]]) {{.*}}: (f64) -> f64
25 ! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f64>
26 b = log(a)
27 end subroutine
29 ! CHECK-LABEL: log_testc
30 ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref<complex<f32>> {{.*}}, %[[BREF:.*]]: !fir.ref<complex<f32>> {{.*}})
31 subroutine log_testc(a, b)
32 complex :: a, b
33 ! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<complex<f32>>
34 ! CHECK: %[[RES:.*]] = fir.call @fir.log.contract.z32.z32(%[[A]]) {{.*}}: (complex<f32>) -> complex<f32>
35 ! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<complex<f32>>
36 b = log(a)
37 end subroutine
39 ! CHECK-LABEL: log_testcd
40 ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref<complex<f64>> {{.*}}, %[[BREF:.*]]: !fir.ref<complex<f64>> {{.*}})
41 subroutine log_testcd(a, b)
42 complex(kind=8) :: a, b
43 ! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<complex<f64>>
44 ! CHECK: %[[RES:.*]] = fir.call @fir.log.contract.z64.z64(%[[A]]) {{.*}}: (complex<f64>) -> complex<f64>
45 ! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<complex<f64>>
46 b = log(a)
47 end subroutine
49 ! CHECK-LABEL: log10_testr
50 ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref<f32> {{.*}}, %[[BREF:.*]]: !fir.ref<f32> {{.*}})
51 subroutine log10_testr(a, b)
52 real :: a, b
53 ! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f32>
54 ! CHECK: %[[RES:.*]] = fir.call @fir.log10.contract.f32.f32(%[[A]]) {{.*}}: (f32) -> f32
55 ! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f32>
56 b = log10(a)
57 end subroutine
59 ! CHECK-LABEL: log10_testd
60 ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref<f64> {{.*}}, %[[BREF:.*]]: !fir.ref<f64> {{.*}})
61 subroutine log10_testd(a, b)
62 real(kind=8) :: a, b
63 ! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f64>
64 ! CHECK: %[[RES:.*]] = fir.call @fir.log10.contract.f64.f64(%[[A]]) {{.*}}: (f64) -> f64
65 ! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f64>
66 b = log10(a)
67 end subroutine
69 ! CHECK-LABEL: private @fir.log.contract.f32.f32
70 ! CHECK-SAME: (%[[ARG32_OUTLINE:.*]]: f32) -> f32
71 ! CHECK: %[[RESULT32_OUTLINE:.*]] = math.log %[[ARG32_OUTLINE]] fastmath<contract> : f32
72 ! CHECK: return %[[RESULT32_OUTLINE]] : f32
74 ! CHECK-LABEL: private @fir.log.contract.f64.f64
75 ! CHECK-SAME: (%[[ARG64_OUTLINE:.*]]: f64) -> f64
76 ! CHECK: %[[RESULT64_OUTLINE:.*]] = math.log %[[ARG64_OUTLINE]] fastmath<contract> : f64
77 ! CHECK: return %[[RESULT64_OUTLINE]] : f64
79 ! CMPLX-APPROX-LABEL: private @fir.log.contract_afn.z32.z32
80 ! CMPLX-PRECISE-LABEL: private @fir.log.contract.z32.z32
81 ! CMPLX-MLIR-LABEL: private @fir.log.contract.z32.z32
82 ! CMPLX-SAME: (%[[C:.*]]: complex<f32>) -> complex<f32>
83 ! CMPLX-FAST: %[[E:.*]] = complex.log %[[C]] fastmath<contract> : complex<f32>
84 ! CMPLX-APPROX: %[[E:.*]] = complex.log %[[C]] fastmath<contract,afn> : complex<f32>
85 ! CMPLX-PRECISE: %[[E:.*]] = fir.call @clogf(%[[C]]) fastmath<contract> : (complex<f32>) -> complex<f32>
86 ! CMPLX: return %[[E]] : complex<f32>
88 ! CMPLX-APPROX-LABEL: private @fir.log.contract_afn.z64.z64
89 ! CMPLX-PRECISE-LABEL: private @fir.log.contract.z64.z64
90 ! CMPLX-MLIR-LABEL: private @fir.log.contract.z64.z64
91 ! CMPLX-SAME: (%[[C:.*]]: complex<f64>) -> complex<f64>
92 ! CMPLX-FAST: %[[E:.*]] = complex.log %[[C]] fastmath<contract> : complex<f64>
93 ! CMPLX-APPROX: %[[E:.*]] = complex.log %[[C]] fastmath<contract,afn> : complex<f64>
94 ! COMMON-LOG: %[[E:.*]] = fir.call @clog(%[[C]]) fastmath<contract> : (complex<f64>) -> complex<f64>
95 ! AIX-LOG: %[[E:.*]] = fir.call @__clog(%[[C]]) fastmath<contract> : (complex<f64>) -> complex<f64>
96 ! CMPLX: return %[[E]] : complex<f64>
98 ! CHECK-LABEL: private @fir.log10.contract.f32.f32
99 ! CHECK-SAME: (%[[ARG32_OUTLINE:.*]]: f32) -> f32
100 ! CHECK: %[[RESULT32_OUTLINE:.*]] = math.log10 %[[ARG32_OUTLINE]] fastmath<contract> : f32
101 ! CHECK: return %[[RESULT32_OUTLINE]] : f32
103 ! CHECK-LABEL: private @fir.log10.contract.f64.f64
104 ! CHECK-SAME: (%[[ARG64_OUTLINE:.*]]: f64) -> f64
105 ! CHECK: %[[RESULT64_OUTLINE:.*]] = math.log10 %[[ARG64_OUTLINE]] fastmath<contract> : f64
106 ! CHECK: return %[[RESULT64_OUTLINE]] : f64