[llvm] [RISCV] Lower non-power-of-2 vector to nearest power-of-2 vector leng… (PR #106092)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 08:33:28 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 1193f7d6487d2d94009f8d8d27da3907136482b9 a7a504426c28ab95b700f34e6bf5c381574bac25 --extensions cpp,h -- llvm/lib/Target/RISCV/RISCVLegalizeNonPowerOf2Vector.cpp llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp llvm/lib/Target/RISCV/RISCV.h llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index ca6b600ece..343bac491d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -22,10 +22,10 @@
 #include "LegalizeTypes.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/Analysis/MemoryLocation.h"
+#include "llvm/Analysis/ValueTracking.h"
 #include "llvm/Analysis/VectorUtils.h"
 #include "llvm/CodeGen/ISDOpcodes.h"
 #include "llvm/IR/DataLayout.h"
-#include "llvm/Analysis/ValueTracking.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/TypeSize.h"
 #include "llvm/Support/raw_ostream.h"
@@ -5688,16 +5688,16 @@ SDValue DAGTypeLegalizer::WidenVecRes_EXTRACT_SUBVECTOR(SDNode *N) {
   unsigned InNumElts = InVT.getVectorMinNumElements();
   unsigned VTNumElts = VT.getVectorMinNumElements();
 
-  if (InVT.isScalableVector())
-  {
-     unsigned EltSize = InVT.getScalarType ().getFixedSizeInBits ();
+  if (InVT.isScalableVector()) {
+    unsigned EltSize = InVT.getScalarType().getFixedSizeInBits();
 
-     unsigned MinVScale = getVScaleRange(&DAG.getMachineFunction ().getFunction(), 64)
-                                 .getUnsignedMin().getZExtValue ();
-     InNumElts = InNumElts * MinVScale;
+    unsigned MinVScale =
+        getVScaleRange(&DAG.getMachineFunction().getFunction(), 64)
+            .getUnsignedMin()
+            .getZExtValue();
+    InNumElts = InNumElts * MinVScale;
   }
 
-
   assert(IdxVal % VTNumElts == 0 &&
          "Expected Idx to be a multiple of subvector minimum vector length");
   if (IdxVal % WidenNumElts == 0 && IdxVal + WidenNumElts < InNumElts)
diff --git a/llvm/lib/Target/RISCV/RISCVLegalizeNonPowerOf2Vector.cpp b/llvm/lib/Target/RISCV/RISCVLegalizeNonPowerOf2Vector.cpp
index 98bca6b96f..d0216fcde1 100644
--- a/llvm/lib/Target/RISCV/RISCVLegalizeNonPowerOf2Vector.cpp
+++ b/llvm/lib/Target/RISCV/RISCVLegalizeNonPowerOf2Vector.cpp
@@ -64,13 +64,13 @@ RISCVLegalizeNonPowerOf2Vector::getContainerForFixedLengthVector(
     FixedVectorType *FixedVecTy) {
   // TODO: Consider vscale_range to pick a better/smaller type.
   //
-  uint64_t 	 NumElts =
-      std::max<uint64_t>((NextPowerOf2 (FixedVecTy->getNumElements()) / MinVScale), 1);
+  uint64_t NumElts = std::max<uint64_t>(
+      (NextPowerOf2(FixedVecTy->getNumElements()) / MinVScale), 1);
 
   Type *ElementType = FixedVecTy->getElementType();
 
   if (ElementType->isIntegerTy(1))
-      NumElts = std::max(NumElts, 8UL);
+    NumElts = std::max(NumElts, 8UL);
 
   return ScalableVectorType::get(ElementType, NumElts);
 }
@@ -114,17 +114,16 @@ bool RISCVLegalizeNonPowerOf2Vector::runOnFunction(Function &F) {
 
   auto Attr = F.getFnAttribute(Attribute::VScaleRange);
   if (Attr.isValid()) {
-      MinVScale = Attr.getVScaleRangeMin ();
+    MinVScale = Attr.getVScaleRangeMin();
   } else {
     unsigned MinVLen = ST->getRealMinVLen();
     if (MinVLen < RISCV::RVVBitsPerBlock)
       return false;
     MinVScale = MinVLen / RISCV::RVVBitsPerBlock;
     AttrBuilder AB(F.getContext());
-    AB.addVScaleRangeAttr(MinVScale,
-                         std::optional<unsigned>());
+    AB.addVScaleRangeAttr(MinVScale, std::optional<unsigned>());
 
-    F.addFnAttr (AB.getAttribute(Attribute::VScaleRange));
+    F.addFnAttr(AB.getAttribute(Attribute::VScaleRange));
   }
 
   bool Modified = false;

``````````

</details>


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


More information about the llvm-commits mailing list