Skip to content

Commit 3137fd7

Browse files
mjklemmPriyanshu3820
authored andcommitted
[Flang] Add -ffast-real-mod back for further control of MOD optimizations (llvm#167118)
It turns out that having `-ffast-math` as the only option to control optimizations for MOD for REAL kinds (PR llvm#160660) is too coarse-grained for some applications. Thus, this PR adds back `-ffast-real-mod` to have more control over the optimization. The `-ffast-math` flag will still enable the optimization, and `-fno-fast-real-mod` allows one to disable it.
1 parent 49aefe1 commit 3137fd7

File tree

8 files changed

+127
-60
lines changed

8 files changed

+127
-60
lines changed

clang/include/clang/Options/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,6 +2788,9 @@ def fno_unsafe_math_optimizations : Flag<["-"], "fno-unsafe-math-optimizations">
27882788
Group<f_Group>;
27892789
def fassociative_math : Flag<["-"], "fassociative-math">, Visibility<[ClangOption, FlangOption]>, Group<f_Group>;
27902790
def fno_associative_math : Flag<["-"], "fno-associative-math">, Visibility<[ClangOption, FlangOption]>, Group<f_Group>;
2791+
def ffast_real_mod : Flag<["-"], "ffast-real-mod">,
2792+
Group<f_Group>, Visibility<[FlangOption, FC1Option]>,
2793+
HelpText<"Enable optimization of MOD for REAL types">;
27912794
def fno_fast_real_mod : Flag<["-"], "fno-fast-real-mod">,
27922795
Group<f_Group>, Visibility<[FlangOption, FC1Option]>,
27932796
HelpText<"Disable optimization of MOD for REAL types in presence of -ffast-math">;

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,14 @@ static void addFloatingPointOptions(const Driver &D, const ArgList &Args,
822822
complexRangeKindToStr(Range)));
823823
}
824824

825-
if (Args.hasArg(options::OPT_fno_fast_real_mod))
826-
CmdArgs.push_back("-fno-fast-real-mod");
825+
if (llvm::opt::Arg *A =
826+
Args.getLastArg(clang::options::OPT_ffast_real_mod,
827+
clang::options::OPT_fno_fast_real_mod)) {
828+
if (A->getOption().matches(clang::options::OPT_ffast_real_mod))
829+
CmdArgs.push_back("-ffast-real-mod");
830+
else if (A->getOption().matches(clang::options::OPT_fno_fast_real_mod))
831+
CmdArgs.push_back("-fno-fast-real-mod");
832+
}
827833

828834
if (!HonorINFs && !HonorNaNs && AssociativeMath && ReciprocalMath &&
829835
ApproxFunc && !SignedZeros &&

flang/include/flang/Support/LangOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ LANGOPT(OpenMPNoNestedParallelism, 1, 0)
6161
/// Use SIMD only OpenMP support.
6262
LANGOPT(OpenMPSimd, 1, false)
6363
/// Enable fast MOD operations for REAL
64-
LANGOPT(NoFastRealMod, 1, false)
64+
LANGOPT(FastRealMod, 1, false)
6565
LANGOPT(VScaleMin, 32, 0) ///< Minimum vscale range value
6666
LANGOPT(VScaleMax, 32, 0) ///< Maximum vscale range value
6767

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,18 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
14031403
opts.ReciprocalMath = true;
14041404
opts.ApproxFunc = true;
14051405
opts.NoSignedZeros = true;
1406+
opts.FastRealMod = true;
14061407
opts.setFPContractMode(Fortran::common::LangOptions::FPM_Fast);
14071408
}
14081409

1409-
if (args.hasArg(clang::options::OPT_fno_fast_real_mod))
1410-
opts.NoFastRealMod = true;
1410+
if (llvm::opt::Arg *arg =
1411+
args.getLastArg(clang::options::OPT_ffast_real_mod,
1412+
clang::options::OPT_fno_fast_real_mod)) {
1413+
if (arg->getOption().matches(clang::options::OPT_ffast_real_mod))
1414+
opts.FastRealMod = true;
1415+
if (arg->getOption().matches(clang::options::OPT_fno_fast_real_mod))
1416+
opts.FastRealMod = false;
1417+
}
14111418

14121419
return true;
14131420
}

flang/lib/Frontend/FrontendActions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ bool CodeGenAction::beginSourceFileAction() {
277277
ci.getInvocation().getLangOpts().OpenMPVersion);
278278
}
279279

280-
if (ci.getInvocation().getLangOpts().NoFastRealMod) {
280+
if (ci.getInvocation().getLangOpts().FastRealMod) {
281281
mlir::ModuleOp mod = lb.getModule();
282282
mod.getOperation()->setAttr(
283283
mlir::StringAttr::get(mod.getContext(),
284-
llvm::Twine{"fir.no_fast_real_mod"}),
284+
llvm::Twine{"fir.fast_real_mod"}),
285285
mlir::BoolAttr::get(mod.getContext(), true));
286286
}
287287

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6526,11 +6526,9 @@ static mlir::Value genFastMod(fir::FirOpBuilder &builder, mlir::Location loc,
65266526
mlir::Value IntrinsicLibrary::genMod(mlir::Type resultType,
65276527
llvm::ArrayRef<mlir::Value> args) {
65286528
auto mod = builder.getModule();
6529-
bool dontUseFastRealMod = false;
6530-
bool canUseApprox = mlir::arith::bitEnumContainsAny(
6531-
builder.getFastMathFlags(), mlir::arith::FastMathFlags::afn);
6532-
if (auto attr = mod->getAttrOfType<mlir::BoolAttr>("fir.no_fast_real_mod"))
6533-
dontUseFastRealMod = attr.getValue();
6529+
bool useFastRealMod = false;
6530+
if (auto attr = mod->getAttrOfType<mlir::BoolAttr>("fir.fast_real_mod"))
6531+
useFastRealMod = attr.getValue();
65346532

65356533
assert(args.size() == 2);
65366534
if (resultType.isUnsignedInteger()) {
@@ -6543,7 +6541,7 @@ mlir::Value IntrinsicLibrary::genMod(mlir::Type resultType,
65436541
if (mlir::isa<mlir::IntegerType>(resultType))
65446542
return mlir::arith::RemSIOp::create(builder, loc, args[0], args[1]);
65456543

6546-
if (resultType.isFloat() && canUseApprox && !dontUseFastRealMod) {
6544+
if (resultType.isFloat() && useFastRealMod) {
65476545
// Treat MOD as an approximate function and code-gen inline code
65486546
// instead of calling into the Fortran runtime library.
65496547
return builder.createConvert(loc, resultType,

flang/test/Driver/fast-real-mod.f90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
! RUN: %flang -ffast-real-mod -### -c %s 2>&1 | FileCheck %s -check-prefix CHECK-FAST-REAL-MOD
12
! RUN: %flang -fno-fast-real-mod -### -c %s 2>&1 | FileCheck %s -check-prefix CHECK-NO-FAST-REAL-MOD
3+
! RUN: %flang -fno-fast-real-mod -ffast-real-mod -### -c %s 2>&1 | FileCheck %s -check-prefix CHECK-FAST-REAL-MOD
4+
! RUN: %flang -ffast-real-mod -fno-fast-real-mod -### -c %s 2>&1 | FileCheck %s -check-prefix CHECK-NO-FAST-REAL-MOD
25

6+
! CHECK-FAST-REAL-MOD: "-ffast-real-mod"
7+
! CHECK-FAST-REAL-MOD-NOT: "-fno-fast-real-mod"
38
! CHECK-NO-FAST-REAL-MOD: "-fno-fast-real-mod"
9+
! CHECK-NO-FAST-REAL-MOD-NOT: "-fast-real-mod"
410

511
program test
612
! nothing to be done in here
Lines changed: 94 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
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%}
1+
! RUN: %flang_fc1 -ffast-real-mod -emit-mlir -o - %s | FileCheck %s --check-prefixes=CHECK-FRM%if target=x86_64{{.*}} %{,CHECK-FRM-KIND10%}%if flang-supports-f128-math %{,CHECK-FRM-KIND16%}
2+
! RUN: %flang_fc1 -ffast-real-mod -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+
! RUN: %flang_fc1 -fno-fast-real-mod -ffast-real-mod -emit-mlir -o - %s | FileCheck %s --check-prefixes=CHECK-FRM%if target=x86_64{{.*}} %{,CHECK-FRM-KIND10%}%if flang-supports-f128-math %{,CHECK-FRM-KIND16%}
4+
! RUN: %flang_fc1 -ffast-math -emit-mlir -o - %s | FileCheck %s --check-prefixes=CHECK-FM%if target=x86_64{{.*}} %{,CHECK-FM-KIND10%}%if flang-supports-f128-math %{,CHECK-FM-KIND16%}
25
! 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%}
36

4-
! TODO: check line that fir.fast_real_mod is not there
5-
! CHECK-NFRM: module attributes {{{.*}}fir.no_fast_real_mod = true{{.*}}}
7+
! CHECK-FM: module attributes {{{.*}}fir.fast_real_mod = true{{.*}}}
8+
! CHECK-FRM: module attributes {{{.*}}fir.fast_real_mod = true{{.*}}}
69

710
! CHECK-LABEL: @_QPmod_real4
811
subroutine mod_real4(r, a, p)
912
implicit none
1013
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>
14+
! CHECK-FRM: %[[A:.*]] = fir.declare{{.*}}a"
15+
! CHECK-FRM: %[[P:.*]] = fir.declare{{.*}}p"
16+
! CHECK-FRM: %[[R:.*]] = fir.declare{{.*}}r"
17+
! CHECK-FRM: %[[A_LOAD:.*]] = fir.load %[[A]]
18+
! CHECK-FRM: %[[P_LOAD:.*]] = fir.load %[[P]]
19+
! CHECK-FRM: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<contract> : f32
20+
! CHECK-FRM: %[[CV1:.*]] = fir.convert %[[DIV]] : (f32) -> si32
21+
! CHECK-FRM: %[[CV2:.*]] = fir.convert %[[CV1]] : (si32) -> f32
22+
! CHECK-FRM: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<contract> : f32
23+
! CHECK-FRM: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<contract> : f32
24+
! CHECK-FRM: fir.store %[[SUB]] to %[[R]] : !fir.ref<f32>
25+
! CHECK-FM: %[[A:.*]] = fir.declare{{.*}}a"
26+
! CHECK-FM: %[[P:.*]] = fir.declare{{.*}}p"
27+
! CHECK-FM: %[[R:.*]] = fir.declare{{.*}}r"
28+
! CHECK-FM: %[[A_LOAD:.*]] = fir.load %[[A]]
29+
! CHECK-FM: %[[P_LOAD:.*]] = fir.load %[[P]]
30+
! CHECK-FM: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<fast> : f32
31+
! CHECK-FM: %[[CV1:.*]] = fir.convert %[[DIV]] : (f32) -> si32
32+
! CHECK-FM: %[[CV2:.*]] = fir.convert %[[CV1]] : (si32) -> f32
33+
! CHECK-FM: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<fast> : f32
34+
! CHECK-FM: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<fast> : f32
35+
! CHECK-FM: fir.store %[[SUB]] to %[[R]] : !fir.ref<f32>
2236
! CHECK-NFRM: fir.call @_FortranAModReal4(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (f32, f32, !fir.ref<i8>, i32) -> f32
2337
r = mod(a, p)
2438
end subroutine mod_real4
@@ -27,17 +41,28 @@ end subroutine mod_real4
2741
subroutine mod_real8(r, a, p)
2842
implicit none
2943
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>
44+
! CHECK-FRM: %[[A:.*]] = fir.declare{{.*}}a"
45+
! CHECK-FRM: %[[P:.*]] = fir.declare{{.*}}p"
46+
! CHECK-FRM: %[[R:.*]] = fir.declare{{.*}}r"
47+
! CHECK-FRM: %[[A_LOAD:.*]] = fir.load %[[A]]
48+
! CHECK-FRM: %[[P_LOAD:.*]] = fir.load %[[P]]
49+
! CHECK-FRM: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<contract> : f64
50+
! CHECK-FRM: %[[CV1:.*]] = fir.convert %[[DIV]] : (f64) -> si64
51+
! CHECK-FRM: %[[CV2:.*]] = fir.convert %[[CV1]] : (si64) -> f64
52+
! CHECK-FRM: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<contract> : f64
53+
! CHECK-FRM: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<contract> : f64
54+
! CHECK-FRM: fir.store %[[SUB]] to %[[R]] : !fir.ref<f64>
55+
! CHECK-FM: %[[A:.*]] = fir.declare{{.*}}a"
56+
! CHECK-FM: %[[P:.*]] = fir.declare{{.*}}p"
57+
! CHECK-FM: %[[R:.*]] = fir.declare{{.*}}r"
58+
! CHECK-FM: %[[A_LOAD:.*]] = fir.load %[[A]]
59+
! CHECK-FM: %[[P_LOAD:.*]] = fir.load %[[P]]
60+
! CHECK-FM: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<fast> : f64
61+
! CHECK-FM: %[[CV1:.*]] = fir.convert %[[DIV]] : (f64) -> si64
62+
! CHECK-FM: %[[CV2:.*]] = fir.convert %[[CV1]] : (si64) -> f64
63+
! CHECK-FM: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<fast> : f64
64+
! CHECK-FM: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<fast> : f64
65+
! CHECK-FM: fir.store %[[SUB]] to %[[R]] : !fir.ref<f64>
4166
! CHECK-NFRM: fir.call @_FortranAModReal8(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (f64, f64, !fir.ref<i8>, i32) -> f64
4267
r = mod(a, p)
4368
end subroutine mod_real8
@@ -47,17 +72,28 @@ subroutine mod_real10(r, a, p)
4772
implicit none
4873
integer, parameter :: kind10 = merge(10, 4, selected_real_kind(p=18).eq.10)
4974
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>
75+
! CHECK-FRM-KIND10: %[[A:.*]] = fir.declare{{.*}}a"
76+
! CHECK-FRM-KIND10: %[[P:.*]] = fir.declare{{.*}}p"
77+
! CHECK-FRM-KIND10: %[[R:.*]] = fir.declare{{.*}}r"
78+
! CHECK-FRM-KIND10: %[[A_LOAD:.*]] = fir.load %[[A]]
79+
! CHECK-FRM-KIND10: %[[P_LOAD:.*]] = fir.load %[[P]]
80+
! CHECK-FRM-KIND10: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<contract> : f80
81+
! CHECK-FRM-KIND10: %[[CV1:.*]] = fir.convert %[[DIV]] : (f80) -> si80
82+
! CHECK-FRM-KIND10: %[[CV2:.*]] = fir.convert %[[CV1]] : (si80) -> f80
83+
! CHECK-FRM-KIND10: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<contract> : f80
84+
! CHECK-FRM-KIND10: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<contract> : f80
85+
! CHECK-FRM-KIND10: fir.store %[[SUB]] to %[[R]] : !fir.ref<f80>
86+
! CHECK-FM-KIND10: %[[A:.*]] = fir.declare{{.*}}a"
87+
! CHECK-FM-KIND10: %[[P:.*]] = fir.declare{{.*}}p"
88+
! CHECK-FM-KIND10: %[[R:.*]] = fir.declare{{.*}}r"
89+
! CHECK-FM-KIND10: %[[A_LOAD:.*]] = fir.load %[[A]]
90+
! CHECK-FM-KIND10: %[[P_LOAD:.*]] = fir.load %[[P]]
91+
! CHECK-FM-KIND10: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<fast> : f80
92+
! CHECK-FM-KIND10: %[[CV1:.*]] = fir.convert %[[DIV]] : (f80) -> si80
93+
! CHECK-FM-KIND10: %[[CV2:.*]] = fir.convert %[[CV1]] : (si80) -> f80
94+
! CHECK-FM-KIND10: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<fast> : f80
95+
! CHECK-FM-KIND10: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<fast> : f80
96+
! CHECK-FM-KIND10: fir.store %[[SUB]] to %[[R]] : !fir.ref<f80>
6197
! CHECK-NFRM-KIND10: fir.call @_FortranAModReal10(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (f80, f80, !fir.ref<i8>, i32) -> f80
6298
r = mod(a, p)
6399
end subroutine mod_real10
@@ -67,17 +103,28 @@ subroutine mod_real16(r, a, p)
67103
implicit none
68104
integer, parameter :: kind16 = merge(16, 4, selected_real_kind(p=33).eq.16)
69105
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>
106+
! CHECK-FRM-KIND16: %[[A:.*]] = fir.declare{{.*}}a"
107+
! CHECK-FRM-KIND16: %[[P:.*]] = fir.declare{{.*}}p"
108+
! CHECK-FRM-KIND16: %[[R:.*]] = fir.declare{{.*}}r"
109+
! CHECK-FRM-KIND16: %[[A_LOAD:.*]] = fir.load %[[A]]
110+
! CHECK-FRM-KIND16: %[[P_LOAD:.*]] = fir.load %[[P]]
111+
! CHECK-FRM-KIND16: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<contract> : f128
112+
! CHECK-FRM-KIND16: %[[CV1:.*]] = fir.convert %[[DIV]] : (f128) -> si128
113+
! CHECK-FRM-KIND16: %[[CV2:.*]] = fir.convert %[[CV1]] : (si128) -> f128
114+
! CHECK-FRM-KIND16: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<contract> : f128
115+
! CHECK-FRM-KIND16: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<contract> : f128
116+
! CHECK-FRM-KIND16: fir.store %[[SUB]] to %[[R]] : !fir.ref<f128>
117+
! CHECK-FM-KIND16: %[[A:.*]] = fir.declare{{.*}}a"
118+
! CHECK-FM-KIND16: %[[P:.*]] = fir.declare{{.*}}p"
119+
! CHECK-FM-KIND16: %[[R:.*]] = fir.declare{{.*}}r"
120+
! CHECK-FM-KIND16: %[[A_LOAD:.*]] = fir.load %[[A]]
121+
! CHECK-FM-KIND16: %[[P_LOAD:.*]] = fir.load %[[P]]
122+
! CHECK-FM-KIND16: %[[DIV:.*]] = arith.divf %[[A_LOAD]], %[[P_LOAD]] fastmath<fast> : f128
123+
! CHECK-FM-KIND16: %[[CV1:.*]] = fir.convert %[[DIV]] : (f128) -> si128
124+
! CHECK-FM-KIND16: %[[CV2:.*]] = fir.convert %[[CV1]] : (si128) -> f128
125+
! CHECK-FM-KIND16: %[[MUL:.*]] = arith.mulf %[[CV2]], %[[P_LOAD]] fastmath<fast> : f128
126+
! CHECK-FM-KIND16: %[[SUB:.*]] = arith.subf %[[A_LOAD]], %[[MUL]] fastmath<fast> : f128
127+
! CHECK-FM-KIND16: fir.store %[[SUB]] to %[[R]] : !fir.ref<f128>
81128
! CHECK-NFRM-KIND16: fir.call @_FortranAModReal16(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (f128, f128, !fir.ref<i8>, i32) -> f128
82129
r = mod(a, p)
83130
end subroutine mod_real16

0 commit comments

Comments
 (0)