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) {
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue