[PATCH] D156026: [InstCombine] Contracting x^2 + 2*x*y + y^2 to (x + y)^2 (integer)
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 23 09:19:26 PDT 2023
nikic 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)));
+}
----------------
rainerzufalldererste wrote:
> 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?
You can use `m_CombineOr`
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