[PATCH] D123399: [InstCombine] Fold sub(add(x,y),min/max(x,y)) -> max/min(x,y) (PR38280)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 10 11:46:53 PDT 2022


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:2017
+    if (match(Op0, m_Add(m_Value(X), m_Value(Y))) &&
+        match(Op1, m_c_MaxOrMin(m_Specific(X), m_Specific(Y))) &&
+        (Op0->hasOneUse() || Op1->hasOneUse())) {
----------------
I believe m_c_MaxOrMin also accepts min/max in select form, which would then assert with the intrinsic cast. Unless we want to adjust the matcher (which we might well want to do now that we canonicalize to intrinsic form, but probably independently of this change) I'd suggest a dyn_cast to MinMaxIntrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123399



More information about the llvm-commits mailing list