[Mlir-commits] [mlir] [mlir][arith] Fix arith maxnumf/minnumf folder (PR #114595)

Jakub Kuderski llvmlistbot at llvm.org
Mon Nov 4 08:03:57 PST 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); });
+  return constFoldBinaryOp<FloatAttr>(adaptor.getOperands(),
+                                      [](const APFloat &a, const APFloat &b) {
+                                        return llvm::maximumnum(a, b);
----------------
kuhar wrote:

This looks incorrect to me since maximumnum != maxnum

https://github.com/llvm/llvm-project/pull/114595


More information about the Mlir-commits mailing list