[llvm] [LV] Vectorization of compress idiom (PR #83467)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 29 11:40:04 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 6c7805d5d186a6d1263f90b8033ad85e2d2633d7 4f6d03ee5c92d85273ebba206c6adf74d67b8862 -- llvm/include/llvm/Analysis/IVDescriptors.h llvm/include/llvm/Analysis/TargetTransformInfo.h llvm/include/llvm/Analysis/TargetTransformInfoImpl.h llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h llvm/lib/Analysis/IVDescriptors.cpp llvm/lib/Analysis/TargetTransformInfo.cpp llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp llvm/lib/Transforms/Vectorize/LoopVectorize.cpp llvm/lib/Transforms/Vectorize/VPlan.cpp llvm/lib/Transforms/Vectorize/VPlan.h llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp llvm/lib/Transforms/Vectorize/VPlanTransforms.h llvm/lib/Transforms/Vectorize/VPlanValue.h
``````````

</details>

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

``````````diff
diff --git a/llvm/include/llvm/Analysis/IVDescriptors.h b/llvm/include/llvm/Analysis/IVDescriptors.h
index 877204a8b2..dd60e84bf1 100644
--- a/llvm/include/llvm/Analysis/IVDescriptors.h
+++ b/llvm/include/llvm/Analysis/IVDescriptors.h
@@ -13,11 +13,11 @@
 #ifndef LLVM_ANALYSIS_IVDESCRIPTORS_H
 #define LLVM_ANALYSIS_IVDESCRIPTORS_H
 
+#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/ValueHandle.h"
-#include "llvm/ADT/SetVector.h"
 
 namespace llvm {
 
@@ -400,7 +400,7 @@ class MonotonicDescriptor {
 public:
   /// This enum represents the kinds of monotonic that we support.
   enum MonotonicKind {
-    MK_None,  ///< Not a monotonic variable.
+    MK_None,    ///< Not a monotonic variable.
     MK_Integer, /// < Integer monotonic variable. Step = C
     MK_Pointer, /// < Pointer monotonic variable. Step = C
   };
diff --git a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
index 9896211ca1..6d998fe1ed 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
@@ -258,8 +258,7 @@ public:
   using InductionList = MapVector<PHINode *, InductionDescriptor>;
 
   /// MonotonicPhiList contains phi nodes that represent monotonic idiom
-  using MonotonicPhiList =
-      MapVector<const PHINode *, MonotonicDescriptor>;
+  using MonotonicPhiList = MapVector<const PHINode *, MonotonicDescriptor>;
 
   /// RecurrenceSet contains the phi nodes that are recurrences other than
   /// inductions and reductions.
@@ -315,7 +314,8 @@ public:
 
   /// Returns the MonotonicDescriptor associated with an \p I instruction
   /// Returns emtpy descriptor if \p I instruction is non-monotonic.
-  const MonotonicDescriptor *getMonotonicDescriptor(const Instruction *I) const {
+  const MonotonicDescriptor *
+  getMonotonicDescriptor(const Instruction *I) const {
     for (const auto &PMD : getMonotonics()) {
       if (const auto *Phi = dyn_cast<const PHINode>(I))
         if (PMD.second.getPhis().contains(const_cast<PHINode *>(Phi)))
diff --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp
index 9194a5622b..dbe1890477 100644
--- a/llvm/lib/Analysis/IVDescriptors.cpp
+++ b/llvm/lib/Analysis/IVDescriptors.cpp
@@ -1575,7 +1575,8 @@ MonotonicDescriptor::isMonotonicPHI(PHINode *Phi, const Loop *L,
 
   // It's important to check all uses of the Phi and make sure they are either
   // outside of the loop.
-  // TODO: Support uses under nested predicate, which can be supported by vectorizer
+  // TODO: Support uses under nested predicate, which can be supported by
+  // vectorizer
   for (User *U : Phi->users()) {
     auto *UI = cast<Instruction>(U);
     if (!L->contains(UI))
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 77348826e0..22ce16a10e 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -494,8 +494,7 @@ bool LoopVectorizationLegality::isConsecutiveMonotonicPtr(Value *Ptr) const {
   return Step && Step->getAPInt().getZExtValue() == 1;
 }
 
-bool LoopVectorizationLegality::ptrHasMonotonicOperand(
-    Value *Ptr) const {
+bool LoopVectorizationLegality::ptrHasMonotonicOperand(Value *Ptr) const {
   auto *GEP = dyn_cast<GetElementPtrInst>(Ptr);
   if (!GEP)
     return false;
@@ -713,7 +712,8 @@ bool LoopVectorizationLegality::canVectorizeOuterLoop() {
   return Result;
 }
 
-bool LoopVectorizationLegality::canVectorizeMonotonic(const MonotonicDescriptor &MD) {
+bool LoopVectorizationLegality::canVectorizeMonotonic(
+    const MonotonicDescriptor &MD) {
   Value *Monotonic = MD.getPhis().front();
   auto IsUserInLoop = [&](User *U) -> bool {
     auto *I = dyn_cast<Instruction>(U);
@@ -962,8 +962,7 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
           continue;
         }
         if (EnableMonotonics && TTI->enableMonotonicVectorization())
-          if (auto MD =
-                  MonotonicDescriptor::isMonotonicPHI(Phi, TheLoop, PSE))
+          if (auto MD = MonotonicDescriptor::isMonotonicPHI(Phi, TheLoop, PSE))
             if (canVectorizeMonotonic(MD)) {
               addMonotonic(MD);
               continue;
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index ab90b5dc50..07bcb08904 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6084,7 +6084,8 @@ LoopVectorizationCostModel::getMonotonicMemoryOpCost(Instruction *I,
     return InstructionCost::getInvalid();
 
   LLVMContext &Ctx = I->getContext();
-  SmallVector<Type *> ParamTys;;
+  SmallVector<Type *> ParamTys;
+  ;
   ParamTys.push_back(VectorTy);
   ParamTys.push_back(Ptr->getType());
   ParamTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), VF));
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 0297b5bae7..3a8b69f2b5 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2254,8 +2254,7 @@ public:
 class VPMonotonicHeaderPHIRecipe final : public VPHeaderPHIRecipe {
 public:
   VPMonotonicHeaderPHIRecipe(PHINode *Phi, VPValue *StartValue)
-      : VPHeaderPHIRecipe(VPDef::VPMonotonicHeaderPHISC, Phi,
-                          StartValue) {}
+      : VPHeaderPHIRecipe(VPDef::VPMonotonicHeaderPHISC, Phi, StartValue) {}
 
   ~VPMonotonicHeaderPHIRecipe() override = default;
 
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 7b06bf99aa..6d568c3cab 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -1145,7 +1145,8 @@ void VPWidenIntOrFpInductionRecipe::print(raw_ostream &O, const Twine &Indent,
   getStepValue()->printAsOperand(O, SlotTracker);
 }
 
-void VPMonotonicUpdateInstruction::print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const {
+void VPMonotonicUpdateInstruction::print(raw_ostream &O, const Twine &Indent,
+                                         VPSlotTracker &SlotTracker) const {
   O << Indent << "monotonic-update ";
   printAsOperand(O, SlotTracker);
   O << " = ";

``````````

</details>


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


More information about the llvm-commits mailing list