[llvm] [InstCombine] Canonicalize `smax(smin(X, MinC), MaxC) -> smin(smax(X, MaxC), MinC)` (PR #136665)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 22 01:21:32 PDT 2025


================
@@ -1924,6 +1924,26 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
       }
     }
 
+    // Canonicalize smax(smin(X, MinC), MaxC) to smin(smax(X, MaxC), MinC)
+    if (IID == Intrinsic::smax) {
+      Constant *MinC, *MaxC;
+      if ((match(I1, m_Constant(MaxC)) &&
----------------
dtcxzyw wrote:

Use `m_ImmConstant` to avoid matching constantexprs.


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


More information about the llvm-commits mailing list