[Mlir-commits] [mlir] [MLIR][Arith] Add rounding mode attribute to `truncf` (PR #86152)
Jakub Kuderski
llvmlistbot at llvm.org
Fri Mar 29 08:17:59 PDT 2024
================
@@ -1398,8 +1420,15 @@ OpFoldResult arith::TruncFOp::fold(FoldAdaptor adaptor) {
const llvm::fltSemantics &targetSemantics = resElemType.getFloatSemantics();
return constFoldCastOp<FloatAttr, FloatAttr>(
adaptor.getOperands(), getType(),
- [&targetSemantics](const APFloat &a, bool &castStatus) {
- FailureOr<APFloat> result = convertFloatValue(a, targetSemantics);
+ [this, &targetSemantics](const APFloat &a, bool &castStatus) {
+ FailureOr<APFloat> result;
+ if (std::optional<RoundingMode> roundingMode = getRoundingmode()) {
----------------
kuhar wrote:
nit: Could we use `getRoundingmode().value_or(theDefault)` to reduce branching?
https://github.com/llvm/llvm-project/pull/86152
More information about the Mlir-commits
mailing list