[llvm] [DAG] Enhance SDPatternMatch to match integer minimum and maximum patterns in addition to the existing ISD nodes. (PR #111774)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 02:30:09 PDT 2024


================
@@ -609,23 +683,27 @@ inline BinaryOpc_match<LHS, RHS, true> m_Xor(const LHS &L, const RHS &R) {
 }
 
 template <typename LHS, typename RHS>
-inline BinaryOpc_match<LHS, RHS, true> m_SMin(const LHS &L, const RHS &R) {
-  return BinaryOpc_match<LHS, RHS, true>(ISD::SMIN, L, R);
+inline auto m_SMin(const LHS &L, const RHS &R) {
----------------
RKSimon wrote:

Based off the discussion with @nikic on #108218 - we need to name these variants m_SMinLike (etc.) - these will match BOTH the ISD node and the MaxMin pattern. We then keep m_SMin (etc.) to just match the ISD node. 

You will then need to update the ABD matchers in DAGCombiner.visitSUB to use the Like variants.

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


More information about the llvm-commits mailing list