[flang-commits] [flang] [mlir] [mlir][math] Replace roundeven call by nearbyint call when target does not have C23 features (PR #88687)
Corentin Ferry via flang-commits
flang-commits at lists.llvm.org
Mon Apr 15 07:41:20 PDT 2024
================
@@ -185,8 +186,15 @@ void mlir::populateMathToLibmConversionPatterns(RewritePatternSet &patterns) {
populatePatternsForOp<math::Log10Op>(patterns, ctx, "log10f", "log10");
populatePatternsForOp<math::Log1pOp>(patterns, ctx, "log1pf", "log1p");
populatePatternsForOp<math::PowFOp>(patterns, ctx, "powf", "pow");
- populatePatternsForOp<math::RoundEvenOp>(patterns, ctx, "roundevenf",
- "roundeven");
+ if (options.allowC23Features)
+ populatePatternsForOp<math::RoundEvenOp>(patterns, ctx, "roundevenf",
+ "roundeven");
+ else if (options.roundingModeIsDefault)
----------------
cferry-AMD wrote:
The "else" case is not implemented in this commit, so we don't lowering the roundeven operation. There, the rounding mode is not assumed to be "round to nearest", and so it would need to be set accordingly if we want to use `nearbyint`.
I'm thinking of a call to `fegetround` to get the current rounding mode, `fesetround` to set it if necessary, and another `fesetround` to restore the previous rounding mode, but this may not be the right approach (makes the generated code use side effects, and may slow it down).
https://github.com/llvm/llvm-project/pull/88687
More information about the flang-commits
mailing list