Skip to content

Commit 1bcbf74

Browse files
authored
[Flang] Revert "[Flang] Add support for -ffast-real-mod (llvm#4164)" (llvm#4284)
2 parents 1144549 + 2049b45 commit 1bcbf74

File tree

7 files changed

+5
-128
lines changed

7 files changed

+5
-128
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2759,7 +2759,6 @@ def fno_unsafe_math_optimizations : Flag<["-"], "fno-unsafe-math-optimizations">
27592759
Group<f_Group>;
27602760
def fassociative_math : Flag<["-"], "fassociative-math">, Visibility<[ClangOption, FlangOption]>, Group<f_Group>;
27612761
def fno_associative_math : Flag<["-"], "fno-associative-math">, Visibility<[ClangOption, FlangOption]>, Group<f_Group>;
2762-
def ffast_real_mod : Flag<["-"], "ffast-real-mod">, Visibility<[FlangOption, FC1Option]>, Group<f_Group>;
27632762
defm reciprocal_math : BoolFOption<"reciprocal-math",
27642763
LangOpts<"AllowRecip">, DefaultFalse,
27652764
PosFlag<SetTrue, [], [ClangOption, CC1Option, FC1Option, FlangOption],
@@ -7576,6 +7575,7 @@ def emit_mlir : Flag<["-"], "emit-mlir">, Alias<emit_fir>;
75767575

75777576
def emit_hlfir : Flag<["-"], "emit-hlfir">, Group<Action_Group>,
75787577
HelpText<"Build the parse tree, then lower it to HLFIR">;
7578+
75797579
} // let Visibility = [FC1Option]
75807580

75817581
//===----------------------------------------------------------------------===//

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,6 @@ static void addFloatingPointOptions(const Driver &D, const ArgList &Args,
857857

858858
if (ReciprocalMath)
859859
CmdArgs.push_back("-freciprocal-math");
860-
861-
if (Args.hasArg(options::OPT_ffast_real_mod))
862-
CmdArgs.push_back("-ffast-real-mod");
863860
}
864861

865862
static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,

flang/include/flang/Support/LangOptions.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ LANGOPT(OpenMPNoThreadState, 1, 0)
6060
LANGOPT(OpenMPNoNestedParallelism, 1, 0)
6161
/// Use SIMD only OpenMP support.
6262
LANGOPT(OpenMPSimd, 1, false)
63-
/// Enable fast MOD operations for REAL
64-
LANGOPT(FastRealMod, 1, false)
63+
6564
LANGOPT(VScaleMin, 32, 0) ///< Minimum vscale range value
6665
LANGOPT(VScaleMax, 32, 0) ///< Maximum vscale range value
6766

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,10 +1444,6 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
14441444
opts.setFPContractMode(Fortran::common::LangOptions::FPM_Fast);
14451445
}
14461446

1447-
if (args.hasArg(clang::driver::options::OPT_ffast_real_mod)) {
1448-
opts.FastRealMod = true;
1449-
}
1450-
14511447
return true;
14521448
}
14531449

flang/lib/Frontend/FrontendActions.cpp

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

280-
if (ci.getInvocation().getLangOpts().FastRealMod) {
281-
auto mod = lb.getModule();
282-
mod.getOperation()->setAttr(
283-
mlir::StringAttr::get(mod.getContext(),
284-
llvm::Twine{"fir.fast_real_mod"}),
285-
mlir::BoolAttr::get(mod.getContext(), true));
286-
}
287-
288280
// Create a parse tree and lower it to FIR
289281
parseAndLowerTree(ci, lb);
290282

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#include "flang/Optimizer/Support/Utils.h"
4747
#include "flang/Runtime/entry-names.h"
4848
#include "flang/Runtime/iostat-consts.h"
49-
#include "flang/Support/LangOptions.h"
5049
#include "mlir/Dialect/Complex/IR/Complex.h"
5150
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
5251
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
@@ -6990,30 +6989,8 @@ mlir::Value IntrinsicLibrary::genMergeBits(mlir::Type resultType,
69906989
}
69916990

69926991
// MOD
6993-
static mlir::Value genFastMod(fir::FirOpBuilder &builder, mlir::Location loc,
6994-
mlir::Value a, mlir::Value p) {
6995-
auto fastmathFlags = mlir::arith::FastMathFlags::contract;
6996-
auto fastmathAttr =
6997-
mlir::arith::FastMathFlagsAttr::get(builder.getContext(), fastmathFlags);
6998-
mlir::Value divResult = mlir::arith::DivFOp::create(builder, loc, a, p, fastmathAttr);
6999-
mlir::Type intType = builder.getIntegerType(
7000-
a.getType().getIntOrFloatBitWidth(), /*signed=*/true);
7001-
mlir::Value intResult = builder.createConvert(loc, intType, divResult);
7002-
mlir::Value cnvResult = builder.createConvert(loc, a.getType(), intResult);
7003-
mlir::Value mulResult =
7004-
mlir::arith::MulFOp::create(builder, loc, cnvResult, p, fastmathAttr);
7005-
mlir::Value subResult =
7006-
mlir::arith::SubFOp::create(builder, loc, a, mulResult, fastmathAttr);
7007-
return subResult;
7008-
}
7009-
70106992
mlir::Value IntrinsicLibrary::genMod(mlir::Type resultType,
70116993
llvm::ArrayRef<mlir::Value> args) {
7012-
auto mod = builder.getModule();
7013-
bool useFastRealMod = false;
7014-
if (auto attr = mod->getAttrOfType<mlir::BoolAttr>("fir.fast_real_mod"))
7015-
useFastRealMod = attr.getValue();
7016-
70176994
assert(args.size() == 2);
70186995
if (resultType.isUnsignedInteger()) {
70196996
mlir::Type signlessType = mlir::IntegerType::get(
@@ -7025,18 +7002,9 @@ mlir::Value IntrinsicLibrary::genMod(mlir::Type resultType,
70257002
if (mlir::isa<mlir::IntegerType>(resultType))
70267003
return mlir::arith::RemSIOp::create(builder, loc, args[0], args[1]);
70277004

7028-
if (useFastRealMod) {
7029-
// If fast MOD for REAL has been requested, generate less precise,
7030-
// but faster code directly.
7031-
assert(resultType.isFloat() &&
7032-
"non floating-point type hit for fast real MOD");
7033-
return builder.createConvert(loc, resultType,
7034-
genFastMod(builder, loc, args[0], args[1]));
7035-
} else {
7036-
// Use runtime.
7037-
return builder.createConvert(
7038-
loc, resultType, fir::runtime::genMod(builder, loc, args[0], args[1]));
7039-
}
7005+
// Use runtime.
7006+
return builder.createConvert(
7007+
loc, resultType, fir::runtime::genMod(builder, loc, args[0], args[1]));
70407008
}
70417009

70427010
// MODULO

flang/test/Lower/Intrinsics/fast-real-mod.f90

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)