145 lines · plain
1! RUN: bbc -emit-fir %s -o - | FileCheck %s2! RUN: bbc --math-runtime=precise -emit-fir %s -o - | FileCheck %s --check-prefix=PRECISE3! RUN: bbc --force-mlir-complex -emit-fir %s -o - | FileCheck %s4! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s5! RUN: %flang_fc1 -fapprox-func -emit-fir %s -o - | FileCheck %s6! RUN: %flang_fc1 -emit-fir -mllvm --math-runtime=precise %s -o - | FileCheck %s --check-prefix=PRECISE7! RUN: %flang_fc1 -emit-fir -mllvm --force-mlir-complex %s -o - | FileCheck %s8 9! Test power operation lowering10 11! CHECK-LABEL: pow_r4_i412subroutine pow_r4_i4(x, y, z)13 real :: x, z14 integer :: y15 z = x ** y16 ! CHECK: math.fpowi {{.*}} : f32, i3217end subroutine18 19! CHECK-LABEL: pow_r4_r420subroutine pow_r4_r4(x, y, z)21 real :: x, z, y22 z = x ** y23 ! CHECK: math.powf %{{.*}}, %{{.*}} : f3224end subroutine25 26! CHECK-LABEL: pow_r4_i827subroutine pow_r4_i8(x, y, z)28 real :: x, z29 integer(8) :: y30 z = x ** y31 ! CHECK: math.fpowi {{.*}} : f32, i6432end subroutine33 34! CHECK-LABEL: pow_r8_i435subroutine pow_r8_i4(x, y, z)36 real(8) :: x, z37 integer :: y38 z = x ** y39 ! CHECK: math.fpowi {{.*}} : f64, i3240end subroutine41 42! CHECK-LABEL: pow_r8_i843subroutine pow_r8_i8(x, y, z)44 real(8) :: x, z45 integer(8) :: y46 z = x ** y47 ! CHECK: math.fpowi {{.*}} : f64, i6448end subroutine49 50! CHECK-LABEL: pow_r8_r851subroutine pow_r8_r8(x, y, z)52 real(8) :: x, z, y53 z = x ** y54 ! CHECK: math.powf %{{.*}}, %{{.*}} : f6455end subroutine56 57! CHECK-LABEL: pow_r4_r858subroutine pow_r4_r8(x, y, z)59 real(4) :: x60 real(8) :: z, y61 z = x ** y62 ! CHECK: %{{.*}} = fir.convert %{{.*}} : (f32) -> f6463 ! CHECK: math.powf %{{.*}}, %{{.*}} : f6464end subroutine65 66! CHECK-LABEL: pow_i1_i167subroutine pow_i1_i1(x, y, z)68 integer(1) :: x, y, z69 z = x ** y70 ! CHECK: math.ipowi %{{.*}}, %{{.*}} : i871end subroutine72 73! CHECK-LABEL: pow_i2_i274subroutine pow_i2_i2(x, y, z)75 integer(2) :: x, y, z76 z = x ** y77 ! CHECK: math.ipowi %{{.*}}, %{{.*}} : i1678end subroutine79 80! CHECK-LABEL: pow_i4_i481subroutine pow_i4_i4(x, y, z)82 integer(4) :: x, y, z83 z = x ** y84 ! CHECK: math.ipowi %{{.*}}, %{{.*}} : i3285end subroutine86 87! CHECK-LABEL: pow_i8_i888subroutine pow_i8_i8(x, y, z)89 integer(8) :: x, y, z90 z = x ** y91 ! CHECK: math.ipowi %{{.*}}, %{{.*}} : i6492end subroutine93 94! CHECK-LABEL: pow_c4_i495subroutine pow_c4_i4(x, y, z)96 complex :: x, z97 integer :: y98 z = x ** y99 ! CHECK: complex.powi %{{.*}}, %{{.*}} : complex<f32>, i32100 ! PRECISE: fir.call @_FortranAcpowi101end subroutine102 103! CHECK-LABEL: pow_c4_i8104subroutine pow_c4_i8(x, y, z)105 complex :: x, z106 integer(8) :: y107 z = x ** y108 ! CHECK: complex.powi %{{.*}}, %{{.*}} : complex<f32>, i64109 ! PRECISE: fir.call @_FortranAcpowk110end subroutine111 112! CHECK-LABEL: pow_c8_i4113subroutine pow_c8_i4(x, y, z)114 complex(8) :: x, z115 integer :: y116 z = x ** y117 ! CHECK: complex.powi %{{.*}}, %{{.*}} : complex<f64>, i32118 ! PRECISE: fir.call @_FortranAzpowi119end subroutine120 121! CHECK-LABEL: pow_c8_i8122subroutine pow_c8_i8(x, y, z)123 complex(8) :: x, z124 integer(8) :: y125 z = x ** y126 ! CHECK: complex.powi %{{.*}}, %{{.*}} : complex<f64>, i64127 ! PRECISE: fir.call @_FortranAzpowk128end subroutine129 130! CHECK-LABEL: pow_c4_c4131subroutine pow_c4_c4(x, y, z)132 complex :: x, y, z133 z = x ** y134 ! CHECK: complex.pow %{{.*}}, %{{.*}} : complex<f32>135 ! PRECISE: fir.call @cpowf136end subroutine137 138! CHECK-LABEL: pow_c8_c8139subroutine pow_c8_c8(x, y, z)140 complex(8) :: x, y, z141 z = x ** y142 ! CHECK: complex.pow %{{.*}}, %{{.*}} : complex<f64>143 ! PRECISE: fir.call @cpow144end subroutine145