[PATCH] D147299: [InstCombine] Add support for maximum(a,b) + minimum(a,b) => a + b

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 3 07:48:49 PDT 2023


RKSimon added a comment.

maximum/minimum propagate nan if present in either argument - I think that's OK here but could do with a second opinion



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1807
 
+  // minumin(X, Y) + maximum(X, Y) => X + Y.
+  if (match(&I,
----------------
minumin -> minimum


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1813
+                                 m_Intrinsic<Intrinsic::minimum>(
+                                     m_Deferred(Y), m_Deferred(X)))))) {
+    return BinaryOperator::CreateFAddFMF(X, Y, &I);
----------------
Its it worth adding a m_c_Intrinsic matcher?


================
Comment at: llvm/test/Transforms/InstCombine/fmul-maximum-minimum.ll:18
+  ret float %res
+}
----------------
vector tests? more commute tests?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147299/new/

https://reviews.llvm.org/D147299



More information about the llvm-commits mailing list