[Mlir-commits] [mlir] [mlir][arith] Fix arith maxnumf/minnumf folder (PR #114595)
Clément Fournier
llvmlistbot at llvm.org
Fri Nov 1 12:24:50 PDT 2024
================
@@ -1014,13 +1014,14 @@ OpFoldResult arith::MaxNumFOp::fold(FoldAdaptor adaptor) {
if (getLhs() == getRhs())
return getRhs();
- // maxnumf(x, -inf) -> x
- if (matchPattern(adaptor.getRhs(), m_NegInfFloat()))
+ // maxnumf(x, NaN) -> x
+ if (matchPattern(adaptor.getRhs(), m_NaNFloat()))
return getLhs();
- return constFoldBinaryOp<FloatAttr>(
- adaptor.getOperands(),
- [](const APFloat &a, const APFloat &b) { return llvm::maximum(a, b); });
----------------
oowekyala wrote:
This matters if the rhs folds to a number, and the LHS folds to NaN. Because this used `maximum` and not `maximumnum`, it would have folded the operation to `NaN` and not to the LHS.
https://github.com/llvm/llvm-project/pull/114595
More information about the Mlir-commits
mailing list