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-
70106992mlir::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
0 commit comments