[llvm] [SLP]Consider (f)sub, being operand of llvm.(f)abs/icmp eq/ne 0, commutative. (PR #86196)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 22 13:47:42 PDT 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 e9639e9c0636d9e2b9591c2cdac5cac75e363e77 f0543e1019eb74ecaa4318278b4acc274e5e1a99 -- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index f32aac549c..09181d7908 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -308,20 +308,19 @@ static bool isCommutative(Instruction *I) {
     return BO->isCommutative() ||
            (BO->getOpcode() == Instruction::Sub &&
             !BO->hasNUsesOrMore(UsesLimit) &&
-            all_of(BO->uses(),
-                   [](const Use &U) {
-                     // Commutative, if icmp eq/ne sub, 0
-                     ICmpInst::Predicate Pred;
-                     if (match(U.getUser(),
-                               m_ICmp(Pred, m_Specific(U.get()), m_Zero())) &&
-                         (Pred == ICmpInst::ICMP_EQ ||
-                          Pred == ICmpInst::ICMP_NE))
-                       return true;
-                     // Commutative, if abs(sub, true).
-                     return match(U.getUser(),
-                                  m_Intrinsic<Intrinsic::abs>(
-                                      m_Specific(U.get()), m_One()));
-                   })) ||
+            all_of(
+                BO->uses(),
+                [](const Use &U) {
+                  // Commutative, if icmp eq/ne sub, 0
+                  ICmpInst::Predicate Pred;
+                  if (match(U.getUser(),
+                            m_ICmp(Pred, m_Specific(U.get()), m_Zero())) &&
+                      (Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE))
+                    return true;
+                  // Commutative, if abs(sub, true).
+                  return match(U.getUser(), m_Intrinsic<Intrinsic::abs>(
+                                                m_Specific(U.get()), m_One()));
+                })) ||
            (BO->getOpcode() == Instruction::FSub &&
             !BO->hasNUsesOrMore(UsesLimit) &&
             all_of(BO->uses(), [](const Use &U) {

``````````

</details>


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


More information about the llvm-commits mailing list