forked from OSchip/llvm-project
[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
This commit is contained in:
parent
7c57180900
commit
238e08d643
|
@ -420,17 +420,11 @@ OpFoldResult math::TanhOp::fold(ArrayRef<Attribute> operands) {
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
OpFoldResult math::RoundEvenOp::fold(ArrayRef<Attribute> operands) {
|
OpFoldResult math::RoundEvenOp::fold(ArrayRef<Attribute> operands) {
|
||||||
return constFoldUnaryOpConditional<FloatAttr>(
|
return constFoldUnaryOp<FloatAttr>(operands, [](const APFloat &a) {
|
||||||
operands, [](const APFloat &a) -> Optional<APFloat> {
|
APFloat result(a);
|
||||||
switch (a.getSizeInBits(a.getSemantics())) {
|
result.roundToIntegral(llvm::RoundingMode::NearestTiesToEven);
|
||||||
case 64:
|
return result;
|
||||||
return APFloat(roundeven(a.convertToDouble()));
|
});
|
||||||
case 32:
|
|
||||||
return APFloat(roundevenf(a.convertToFloat()));
|
|
||||||
default:
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Materialize an integer or floating point constant.
|
/// Materialize an integer or floating point constant.
|
||||||
|
|
Loading…
Reference in New Issue