This revision was automatically updated to reflect the committed changes. Closed by commit rGd0d4b635786d: [flang] add -f[no-]reciprocal-math (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/D137330/new/ https://reviews.llvm.org/D137330 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-hidden.f90 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 @@ -14,6 +14,7 @@ ! RUN: -fapprox-func \ ! RUN: -fno-signed-zeros \ ! RUN: -fassociative-math \ +! RUN: -freciprocal-math \ ! RUN: -mllvm -print-before-all\ ! RUN: -P \ ! RUN: | FileCheck %s @@ -30,5 +31,6 @@ ! CHECK: "-fapprox-func" ! CHECK: "-fno-signed-zeros" ! CHECK: "-mreassociate" +! CHECK: "-freciprocal-math" ! 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 @@ -7,6 +7,7 @@ ! RUN: -fapprox-func \ ! RUN: -fno-signed-zeros \ ! RUN: -mreassociate \ +! RUN: -freciprocal-math \ ! RUN: %s 2>&1 | FileCheck %s ! CHECK: ffp-contract= is not currently implemented ! CHECK: menable-no-infs is not currently implemented @@ -14,3 +15,4 @@ ! CHECK: fapprox-func is not currently implemented ! CHECK: fno-signed-zeros is not currently implemented ! CHECK: mreassociate is not currently implemented +! CHECK: freciprocal-math is not currently implemented Index: flang/test/Driver/driver-help.f90 =================================================================== --- flang/test/Driver/driver-help.f90 +++ flang/test/Driver/driver-help.f90 @@ -46,6 +46,7 @@ ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fopenacc Enable OpenACC ! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. +! HELP-NEXT: -freciprocal-math Allow division operations to be reassociated ! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: -help Display available options @@ -128,6 +129,7 @@ ! HELP-FC1-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-FC1-NEXT: -fopenacc Enable OpenACC ! HELP-FC1-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. +! HELP-FC1-NEXT: -freciprocal-math Allow division operations to be reassociated ! HELP-FC1-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-FC1-NEXT: -help Display available options Index: flang/test/Driver/driver-help-hidden.f90 =================================================================== --- flang/test/Driver/driver-help-hidden.f90 +++ flang/test/Driver/driver-help-hidden.f90 @@ -48,6 +48,7 @@ ! CHECK-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! CHECK-NEXT: -fopenacc Enable OpenACC ! CHECK-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. +! CHECK-NEXT: -freciprocal-math Allow division operations to be reassociated ! CHECK-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! CHECK-NEXT: -help Display available options Index: flang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- flang/lib/Frontend/CompilerInvocation.cpp +++ flang/lib/Frontend/CompilerInvocation.cpp @@ -726,6 +726,12 @@ opts.AssociativeMath = true; } + if (const llvm::opt::Arg *a = + args.getLastArg(clang::driver::options::OPT_freciprocal_math)) { + diags.Report(diagUnimplemented) << a->getOption().getName(); + opts.ReciprocalMath = true; + } + return true; } Index: flang/include/flang/Frontend/LangOptions.def =================================================================== --- flang/include/flang/Frontend/LangOptions.def +++ flang/include/flang/Frontend/LangOptions.def @@ -31,6 +31,8 @@ LANGOPT(NoSignedZeros, 1, false) /// Allow reassociation transformations for floating-point instructions LANGOPT(AssociativeMath, 1, false) +/// Allow division operations to be reassociated +LANGOPT(ReciprocalMath, 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 @@ -88,6 +88,7 @@ bool ApproxFunc = false; bool SignedZeros = true; bool AssociativeMath = false; + bool ReciprocalMath = false; if (const Arg *A = Args.getLastArg(options::OPT_ffp_contract)) { const StringRef Val = A->getValue(); @@ -143,6 +144,12 @@ case options::OPT_fno_associative_math: AssociativeMath = false; break; + case options::OPT_freciprocal_math: + ReciprocalMath = true; + break; + case options::OPT_fno_reciprocal_math: + ReciprocalMath = false; + break; } // If we handled this option claim it @@ -166,6 +173,9 @@ if (AssociativeMath && !SignedZeros) CmdArgs.push_back("-mreassociate"); + + if (ReciprocalMath) + CmdArgs.push_back("-freciprocal-math"); } 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 @@ -1888,7 +1888,7 @@ def fno_associative_math : Flag<["-"], "fno-associative-math">, Group<f_Group>; defm reciprocal_math : BoolFOption<"reciprocal-math", LangOpts<"AllowRecip">, DefaultFalse, - PosFlag<SetTrue, [CC1Option], "Allow division operations to be reassociated", + PosFlag<SetTrue, [CC1Option, FC1Option, FlangOption], "Allow division operations to be reassociated", [funsafe_math_optimizations.KeyPath]>, NegFlag<SetFalse>>; defm approx_func : BoolFOption<"approx-func", LangOpts<"ApproxFunc">, DefaultFalse,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits