[PATCH] D142786: [InstCombine] Improve transforms for (icmp uPred X * Z, Y * Z) -> (icmp uPred X, Y)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 10:19:53 PST 2023


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:4366
+      }
+      // else if (Z == B) -> 'Y' is our 'Y'
+
----------------
goldstein.w.n wrote:
> Is there a better way to do this?
AFAIK, there's no direct way to specify/capture a common operand like that, but this way is shorter and easier to read since it doesn't need any extra operand names:
    if (Pred == ICmpInst::getUnsignedPredicate(Pred) &&
        ((match(Op0, m_Mul(m_Value(X), m_Value(Z))) &&
          match(Op1, m_c_Mul(m_Specific(Z), m_Value(Y)))) ||
         (match(Op0, m_Mul(m_Value(Z), m_Value(X))) &&
          match(Op1, m_c_Mul(m_Specific(Z), m_Value(Y)))))) {



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142786



More information about the llvm-commits mailing list