[llvm] Remove m_OneUse check only for max, not min (PR #81505)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 19:21:24 PST 2024


================
@@ -2265,14 +2265,27 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
 
     // max X, -X --> fabs X
     // min X, -X --> -(fabs X)
-    // TODO: Remove one-use limitation? That is obviously better for max.
-    //       It would be an extra instruction for min (fnabs), but that is
-    //       still likely better for analysis and codegen.
-    if ((match(Arg0, m_OneUse(m_FNeg(m_Value(X)))) && Arg1 == X) ||
-        (match(Arg1, m_OneUse(m_FNeg(m_Value(X)))) && Arg0 == X)) {
+    if ((match(Arg0, m_OneUse(m_FNeg(m_Value(X)))) &&
+         match(Arg1, m_Specific(X))) ||
+        (match(Arg1, m_OneUse(m_FNeg(m_Value(X)))) &&
+         match(Arg0, m_Specific(X)))) {
----------------
arsenm wrote:

Can pre-commit the switch to m_Specific 

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


More information about the llvm-commits mailing list