[flang-commits] [clang] [flang] [Flang] Add -ffast-real-mod and direct code for MOD on REAL types (PR #160660)
Michael Klemm via flang-commits
flang-commits at lists.llvm.org
Mon Sep 29 01:42:45 PDT 2025
================
@@ -7022,9 +7045,16 @@ mlir::Value IntrinsicLibrary::genMod(mlir::Type resultType,
if (mlir::isa<mlir::IntegerType>(resultType))
return mlir::arith::RemSIOp::create(builder, loc, args[0], args[1]);
- // Use runtime.
- return builder.createConvert(
- loc, resultType, fir::runtime::genMod(builder, loc, args[0], args[1]));
+ if (useFastRealMod && resultType.isFloat()) {
----------------
mjklemm wrote:
I was doing that to avoid issues with precision loss that could have come in with the other math functions. After I spoke to the engineers, who are working on the applications, it seems they'd be fine with moving this under the `afn` flag and do the optimization as part of `-ffast-math` which is enabled for this application.
However, I'm tempted to keep this as a separate flag and simply enable this MOD optimization it when `-ffast-math` is present. That makes it more controllable w.r.t. to the other math optimizations. What do you think?
https://github.com/llvm/llvm-project/pull/160660
More information about the flang-commits
mailing list