[llvm] [InstCombine] Add ctpop(A | B) + ctpop(A & B) -> ctpop(A) + ctpop(B) (PR #79089)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 20:02:53 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff f3dd8f10c77f29ff2563482c96c33f2c2bbc847c 6528ccbd8c584017390eb829987c1d1d4c8852bd -- llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 72d0bf475a..d0aff18ee4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1719,13 +1719,15 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
   }
 
   // ctpop(A | B) + ctpop(A & B) -> ctpop(A) + ctpop(B)
-  if (match(&I, m_c_Add(m_OneUse(m_Intrinsic<Intrinsic::ctpop>(
-                       m_And(m_Value(A), m_Value(B))))), mOneUse(m_Intrinsic<Intrinsic::ctpop>(
-                       m_c_Or(m_Specific(A), m_Specific(B)))))))) {
-    return BinaryOperator::CreateAdd(
-               Builder.CreateUnaryIntrinsic(Intrinsic::ctpop, A),
-               Builder.CreateUnaryIntrinsic(Intrinsic::ctpop, B));
-  }
+  if (match(&I,
+            m_c_Add(m_OneUse(
+                m_Intrinsic<Intrinsic::ctpop>(m_And(m_Value(A), m_Value(B))))),
+            mOneUse(m_Intrinsic<Intrinsic::ctpop>(
+                m_c_Or(m_Specific(A), m_Specific(B)))))))) {
+      return BinaryOperator::CreateAdd(
+          Builder.CreateUnaryIntrinsic(Intrinsic::ctpop, A),
+          Builder.CreateUnaryIntrinsic(Intrinsic::ctpop, B));
+    }
 
   // ctpop(A) + ctpop(B) => ctpop(A | B) if A and B have no bits set in common.
   if (match(LHS, m_OneUse(m_Intrinsic<Intrinsic::ctpop>(m_Value(A)))) &&

``````````

</details>


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


More information about the llvm-commits mailing list