[llvm] [InstCombine] Simplify max(min(abs())) (PR #110997)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 11:04:56 PDT 2024


================
@@ -1770,6 +1770,14 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
       }
     }
 
+    // smax(smin(abs(x), y), 0) -> smin(abs(x), y) where y >= 0
+    if (IID == Intrinsic::smax &&
+        match(I0, m_SMin(m_c_Intrinsic<Intrinsic::abs>(m_Value(), m_Value()),
----------------
goldsteinn wrote:

Still need to be `m_c_Intrinsic<..::abs>(m_Value(), m_One())` (And your tests will need toupdated correspondingly.)

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


More information about the llvm-commits mailing list