[PATCH] D156026: [InstCombine] Contracting x^2 + 2*x*y + y^2 to (x + y)^2 (integer)

Christoph Stiller via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 23 08:25:58 PDT 2023


rainerzufalldererste added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1009-1010
+static bool MatchInt2AB(Value *V, Value *&A, Value *&B) {
+  return match(V, m_Shl(m_Mul(m_Value(A), m_Value(B)), m_SpecificInt(1))) ||
+         match(V, m_Mul(m_Shl(m_Value(A), m_SpecificInt(1)), m_Value(B)));
+}
----------------
is there a nice way to do this? maybe a `m_AOrB` / `m_OneOf` or something? because otherwise I don't see how this can be part of a commutative `match(&I, m_c_Add(..., ...))`. Or am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156026



More information about the llvm-commits mailing list