[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 06:45:10 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)
+ populatePatternsForOp<math::RoundEvenOp>(patterns, ctx, "nearbyintf",
+ "nearbyint");
+ // Roundeven: using nearbyint (pre-C23) for roundeven requires the
----------------
cferry-AMD wrote:
Thanks @frederik-h. I have touched `flang` code at some point in an attempt to fix a compile-time bug that went unnoticed on my end, but went backwards and found out I could fix it at the MathToLibm end. So this has nothing to do with Flang... sorry for the noise.
My use case is indeed a C compiler that does not support (yet) roundeven.
https://github.com/llvm/llvm-project/pull/88687
More information about the flang-commits
mailing list