[Mlir-commits] [mlir] 238e08d - [mlir][Math] Fix RoundEven constant folder.
Mehdi Amini
llvmlistbot at llvm.org
Wed Sep 7 05:46:29 PDT 2022
Author: jacquesguan
Date: 2022-09-07T12:46:05Z
New Revision: 238e08d64326572c3d1cf0f8ebd5e3932184a50d
URL: https://github.com/llvm/llvm-project/commit/238e08d64326572c3d1cf0f8ebd5e3932184a50d
DIFF: https://github.com/llvm/llvm-project/commit/238e08d64326572c3d1cf0f8ebd5e3932184a50d.diff
LOG: [mlir][Math] Fix RoundEven constant folder.
Use roundToIntegral instead roundeven of libm to avoid window build failed.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D133402
Added:
Modified:
mlir/lib/Dialect/Math/IR/MathOps.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Math/IR/MathOps.cpp b/mlir/lib/Dialect/Math/IR/MathOps.cpp
index 667c0e66bcd63..567e53b4fad7a 100644
--- a/mlir/lib/Dialect/Math/IR/MathOps.cpp
+++ b/mlir/lib/Dialect/Math/IR/MathOps.cpp
@@ -420,17 +420,11 @@ OpFoldResult math::TanhOp::fold(ArrayRef<Attribute> operands) {
//===----------------------------------------------------------------------===//
OpFoldResult math::RoundEvenOp::fold(ArrayRef<Attribute> operands) {
- return constFoldUnaryOpConditional<FloatAttr>(
- operands, [](const APFloat &a) -> Optional<APFloat> {
- switch (a.getSizeInBits(a.getSemantics())) {
- case 64:
- return APFloat(roundeven(a.convertToDouble()));
- case 32:
- return APFloat(roundevenf(a.convertToFloat()));
- default:
- return {};
- }
- });
+ return constFoldUnaryOp<FloatAttr>(operands, [](const APFloat &a) {
+ APFloat result(a);
+ result.roundToIntegral(llvm::RoundingMode::NearestTiesToEven);
+ return result;
+ });
}
/// Materialize an integer or floating point constant.
More information about the Mlir-commits
mailing list