This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4dc3c029416: [flang] Add -f[no-]associative-math and
-mreassociate (authored by tblah).
Herald added projects: clang, Flang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137329/new/
https://reviews.llvm.org/D137329
Files:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/LangOptions.def
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Driver/driver-help.f90
flang/test/Driver/flang_fp_opts.f90
flang/test/Driver/frontend-forwarding.f90
Index: flang/test/Driver/frontend-forwarding.f90
===================================================================
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -13,6 +13,7 @@
! RUN: -fno-honor-nans \
! RUN: -fapprox-func \
! RUN: -fno-signed-zeros \
+! RUN: -fassociative-math \
! RUN: -mllvm -print-before-all\
! RUN: -P \
! RUN: | FileCheck %s
@@ -28,5 +29,6 @@
! CHECK: "-menable-no-nans"
! CHECK: "-fapprox-func"
! CHECK: "-fno-signed-zeros"
+! CHECK: "-mreassociate"
! CHECK: "-fconvert=little-endian"
! CHECK: "-mllvm" "-print-before-all"
Index: flang/test/Driver/flang_fp_opts.f90
===================================================================
--- flang/test/Driver/flang_fp_opts.f90
+++ flang/test/Driver/flang_fp_opts.f90
@@ -6,9 +6,11 @@
! RUN: -menable-no-nans \
! RUN: -fapprox-func \
! RUN: -fno-signed-zeros \
+! RUN: -mreassociate \
! RUN: %s 2>&1 | FileCheck %s
! CHECK: ffp-contract= is not currently implemented
! CHECK: menable-no-infs is not currently implemented
! CHECK: menable-no-nans is not currently implemented
! CHECK: fapprox-func is not currently implemented
! CHECK: fno-signed-zeros is not currently implemented
+! CHECK: mreassociate is not currently implemented
Index: flang/test/Driver/driver-help.f90
===================================================================
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -140,6 +140,7 @@
! HELP-FC1-NEXT: -mmlir <value> Additional arguments to forward to MLIR's option processing
! HELP-FC1-NEXT: -module-dir <dir> Put MODULE files in <dir>
! HELP-FC1-NEXT: -module-suffix <suffix> Use <suffix> as the suffix for module files (the default value is `.mod`)
+! HELP-FC1-NEXT: -mreassociate Allow reassociation transformations for floating-point instructions
! HELP-FC1-NEXT: -mrelocation-model <value>
! HELP-FC1-NEXT: The relocation model to use
! HELP-FC1-NEXT: -nocpp Disable predefined and command line preprocessor macros
Index: flang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -720,6 +720,12 @@
opts.NoSignedZeros = true;
}
+ if (const llvm::opt::Arg *a =
+ args.getLastArg(clang::driver::options::OPT_mreassociate)) {
+ diags.Report(diagUnimplemented) << a->getOption().getName();
+ opts.AssociativeMath = true;
+ }
+
return true;
}
Index: flang/include/flang/Frontend/LangOptions.def
===================================================================
--- flang/include/flang/Frontend/LangOptions.def
+++ flang/include/flang/Frontend/LangOptions.def
@@ -29,6 +29,8 @@
LANGOPT(ApproxFunc, 1, false)
/// Allow optimizations that ignore the sign of floating point zeros
LANGOPT(NoSignedZeros, 1, false)
+/// Allow reassociation transformations for floating-point instructions
+LANGOPT(AssociativeMath, 1, false)
#undef LANGOPT
#undef ENUM_LANGOPT
Index: clang/lib/Driver/ToolChains/Flang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -87,6 +87,7 @@
bool HonorNaNs = true;
bool ApproxFunc = false;
bool SignedZeros = true;
+ bool AssociativeMath = false;
if (const Arg *A = Args.getLastArg(options::OPT_ffp_contract)) {
const StringRef Val = A->getValue();
@@ -136,6 +137,12 @@
case options::OPT_fno_signed_zeros:
SignedZeros = false;
break;
+ case options::OPT_fassociative_math:
+ AssociativeMath = true;
+ break;
+ case options::OPT_fno_associative_math:
+ AssociativeMath = false;
+ break;
}
// If we handled this option claim it
@@ -156,6 +163,9 @@
if (!SignedZeros)
CmdArgs.push_back("-fno-signed-zeros");
+
+ if (AssociativeMath && !SignedZeros)
+ CmdArgs.push_back("-mreassociate");
}
void Flang::ConstructJob(Compilation &C, const JobAction &JA,
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5444,9 +5444,6 @@
HelpText<"Specify which frame pointers to retain.">, Values<"all,non-leaf,none">,
NormalizedValuesScope<"CodeGenOptions::FramePointerKind">, NormalizedValues<["All", "NonLeaf", "None"]>,
MarshallingInfoEnum<CodeGenOpts<"FramePointer">, "None">;
-def mreassociate : Flag<["-"], "mreassociate">,
- HelpText<"Allow reassociation transformations for floating-point instructions">,
- MarshallingInfoFlag<LangOpts<"AllowFPReassoc">>, ImpliedByAnyOf<[funsafe_math_optimizations.KeyPath]>;
def mabi_EQ_ieeelongdouble : Flag<["-"], "mabi=ieeelongdouble">,
HelpText<"Use IEEE 754 quadruple-precision for long double">,
MarshallingInfoFlag<LangOpts<"PPCIEEELongDouble">>;
@@ -6054,6 +6051,9 @@
let Flags = [CC1Option, FC1Option, NoDriverOption] in {
+def mreassociate : Flag<["-"], "mreassociate">,
+ HelpText<"Allow reassociation transformations for floating-point instructions">,
+ MarshallingInfoFlag<LangOpts<"AllowFPReassoc">>, ImpliedByAnyOf<[funsafe_math_optimizations.KeyPath]>;
def menable_no_nans : Flag<["-"], "menable-no-nans">,
HelpText<"Allow optimization to assume there are no NaNs.">,
MarshallingInfoFlag<LangOpts<"NoHonorNaNs">>, ImpliedByAnyOf<[ffinite_math_only.KeyPath]>;
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits