|
| 1 | +! RUN: %flang_fc1 -ffast-math -emit-mlir -o - %s | FileCheck %s --check-prefixes=CHECK%if target=x86_64{{.*}} %{,CHECK-KIND10%}%if flang-supports-f128-math %{,CHECK-KIND16%} |
| 2 | +! RUN: %flang_fc1 -ffast-math -fno-fast-real-mod -emit-mlir -o - %s | FileCheck %s --check-prefixes=CHECK-NFRM%if target=x86_64{{.*}} %{,CHECK-NFRM-KIND10%}%if flang-supports-f128-math %{,CHECK-NFRM-KIND16%} |
| 3 | + |
| 4 | +! TODO: check line that fir.fast_real_mod is not there |
| 5 | +! CHECK-NFRM: module attributes {{{.*}}fir.no_fast_real_mod = true{{.*}}} |
| 6 | + |
| 7 | +! CHECK-LABEL: @_QPmod_real4 |
| 8 | +subroutine mod_real4(r, a, p) |
| 9 | + implicit none |
| 10 | + real(kind=4) :: r, a, p |
| 11 | +! CHECK: %[[A:.*]] = fir.declare{{.*}}a" |
| 12 | +! CHECK: %[[P:.*]] = fir.declare{{.*}}p" |
| 13 | +! CHECK: %[[R:.*]] = fir.declare{{.*}}r" |
| 14 | +! CHECK: %[[A_LOAD:.*]] = fir.load %[[A]] |
| 15 | +! CHECK: %[[P_LOAD:.*]] = fir.load %[[P]] |
| 16 | +! CHECK: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<fast> : f32 |
| 17 | +! CHECK: %[[CV1:.*]] = fir.convert %[[DIV]] : (f32) -> si32 |
| 18 | +! CHECK: %[[CV2:.*]] = fir.convert %[[CV1]] : (si32) -> f32 |
| 19 | +! CHECK: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<fast> : f32 |
| 20 | +! CHECK: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<fast> : f32 |
| 21 | +! CHECK: fir.store %[[SUB]] to %[[R]] : !fir.ref<f32> |
| 22 | +! CHECK-NFRM: fir.call @_FortranAModReal4(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (f32, f32, !fir.ref<i8>, i32) -> f32 |
| 23 | + r = mod(a, p) |
| 24 | +end subroutine mod_real4 |
| 25 | + |
| 26 | +! CHECK-LABEL: @_QPmod_real8 |
| 27 | +subroutine mod_real8(r, a, p) |
| 28 | + implicit none |
| 29 | + real(kind=8) :: r, a, p |
| 30 | +! CHECK: %[[A:.*]] = fir.declare{{.*}}a" |
| 31 | +! CHECK: %[[P:.*]] = fir.declare{{.*}}p" |
| 32 | +! CHECK: %[[R:.*]] = fir.declare{{.*}}r" |
| 33 | +! CHECK: %[[A_LOAD:.*]] = fir.load %[[A]] |
| 34 | +! CHECK: %[[P_LOAD:.*]] = fir.load %[[P]] |
| 35 | +! CHECK: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<fast> : f64 |
| 36 | +! CHECK: %[[CV1:.*]] = fir.convert %[[DIV]] : (f64) -> si64 |
| 37 | +! CHECK: %[[CV2:.*]] = fir.convert %[[CV1]] : (si64) -> f64 |
| 38 | +! CHECK: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<fast> : f64 |
| 39 | +! CHECK: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<fast> : f64 |
| 40 | +! CHECK: fir.store %[[SUB]] to %[[R]] : !fir.ref<f64> |
| 41 | +! CHECK-NFRM: fir.call @_FortranAModReal8(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (f64, f64, !fir.ref<i8>, i32) -> f64 |
| 42 | + r = mod(a, p) |
| 43 | +end subroutine mod_real8 |
| 44 | + |
| 45 | +! CHECK-LABEL: @_QPmod_real10 |
| 46 | +subroutine mod_real10(r, a, p) |
| 47 | + implicit none |
| 48 | + integer, parameter :: kind10 = merge(10, 4, selected_real_kind(p=18).eq.10) |
| 49 | + real(kind=kind10) :: r, a, p |
| 50 | +! CHECK-KIND10: %[[A:.*]] = fir.declare{{.*}}a" |
| 51 | +! CHECK-KIND10: %[[P:.*]] = fir.declare{{.*}}p" |
| 52 | +! CHECK-KIND10: %[[R:.*]] = fir.declare{{.*}}r" |
| 53 | +! CHECK-KIND10: %[[A_LOAD:.*]] = fir.load %[[A]] |
| 54 | +! CHECK-KIND10: %[[P_LOAD:.*]] = fir.load %[[P]] |
| 55 | +! CHECK-KIND10: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<fast> : f80 |
| 56 | +! CHECK-KIND10: %[[CV1:.*]] = fir.convert %[[DIV]] : (f80) -> si80 |
| 57 | +! CHECK-KIND10: %[[CV2:.*]] = fir.convert %[[CV1]] : (si80) -> f80 |
| 58 | +! CHECK-KIND10: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<fast> : f80 |
| 59 | +! CHECK-KIND10: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<fast> : f80 |
| 60 | +! CHECK-KIND10: fir.store %[[SUB]] to %[[R]] : !fir.ref<f80> |
| 61 | +! CHECK-NFRM-KIND10: fir.call @_FortranAModReal10(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (f80, f80, !fir.ref<i8>, i32) -> f80 |
| 62 | + r = mod(a, p) |
| 63 | +end subroutine mod_real10 |
| 64 | + |
| 65 | +! CHECK-LABEL: @_QPmod_real16 |
| 66 | +subroutine mod_real16(r, a, p) |
| 67 | + implicit none |
| 68 | + integer, parameter :: kind16 = merge(16, 4, selected_real_kind(p=33).eq.16) |
| 69 | + real(kind=kind16) :: r, a, p |
| 70 | +! CHECK-KIND16: %[[A:.*]] = fir.declare{{.*}}a" |
| 71 | +! CHECK-KIND16: %[[P:.*]] = fir.declare{{.*}}p" |
| 72 | +! CHECK-KIND16: %[[R:.*]] = fir.declare{{.*}}r" |
| 73 | +! CHECK-KIND16: %[[A_LOAD:.*]] = fir.load %[[A]] |
| 74 | +! CHECK-KIND16: %[[P_LOAD:.*]] = fir.load %[[P]] |
| 75 | +! CHECK-KIND16: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<fast> : f128 |
| 76 | +! CHECK-KIND16: %[[CV1:.*]] = fir.convert %[[DIV]] : (f128) -> si128 |
| 77 | +! CHECK-KIND16: %[[CV2:.*]] = fir.convert %[[CV1]] : (si128) -> f128 |
| 78 | +! CHECK-KIND16: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<fast> : f128 |
| 79 | +! CHECK-KIND16: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<fast> : f128 |
| 80 | +! CHECK-KIND16: fir.store %[[SUB]] to %[[R]] : !fir.ref<f128> |
| 81 | +! CHECK-NFRM-KIND16: fir.call @_FortranAModReal16(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (f128, f128, !fir.ref<i8>, i32) -> f128 |
| 82 | + r = mod(a, p) |
| 83 | +end subroutine mod_real16 |
0 commit comments