[llvm] [NVPTX] Add NVPTXIncreaseAligmentPass to improve vectorization (PR #144958)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 19 14:28:28 PDT 2025


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 HEAD~1 HEAD --extensions h,cpp -- llvm/lib/Target/NVPTX/NVPTXIncreaseAlignment.cpp llvm/lib/Target/NVPTX/NVPTX.h llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Target/NVPTX/NVPTXIncreaseAlignment.cpp b/llvm/lib/Target/NVPTX/NVPTXIncreaseAlignment.cpp
index cf6d52e0d..5ce01e014 100644
--- a/llvm/lib/Target/NVPTX/NVPTXIncreaseAlignment.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXIncreaseAlignment.cpp
@@ -10,7 +10,7 @@
 // sized and sets an appropriate alignment for them. This enables vectorization
 // of loads/stores to these arrays if not explicitly specified by the client.
 //
-// TODO: Ideally we should do a bin-packing of local arrays to maximize 
+// TODO: Ideally we should do a bin-packing of local arrays to maximize
 // alignments while minimizing holes.
 //
 //===----------------------------------------------------------------------===//
@@ -36,7 +36,8 @@ static constexpr Align MaxPTXArrayAlignment = Align::Constant<16>();
 /// produce holes in the local memory.
 ///
 /// Choose an alignment large enough that the entire array could be loaded with
-/// a single vector load (if possible). Cap the alignment at MaxPTXArrayAlignment.
+/// a single vector load (if possible). Cap the alignment at
+/// MaxPTXArrayAlignment.
 static Align getAggressiveArrayAlignment(const unsigned ArraySize) {
   return std::min(MaxPTXArrayAlignment, Align(PowerOf2Ceil(ArraySize)));
 }
@@ -53,8 +54,7 @@ static Align getConservativeArrayAlignment(const unsigned ArraySize) {
 }
 
 /// Find a better alignment for local arrays
-static bool updateAllocaAlignment(const DataLayout &DL,
-                                         AllocaInst *Alloca) {
+static bool updateAllocaAlignment(const DataLayout &DL, AllocaInst *Alloca) {
   // Looking for statically sized local arrays
   if (!Alloca->isStaticAlloca())
     return false;
@@ -92,7 +92,6 @@ static bool runSetLocalArrayAlignment(Function &F) {
   return Changed;
 }
 
-
 namespace {
 struct NVPTXIncreaseLocalAlignmentLegacyPass : public FunctionPass {
   static char ID;
@@ -103,7 +102,8 @@ struct NVPTXIncreaseLocalAlignmentLegacyPass : public FunctionPass {
 } // namespace
 
 char NVPTXIncreaseLocalAlignmentLegacyPass::ID = 0;
-INITIALIZE_PASS(NVPTXIncreaseLocalAlignmentLegacyPass, "nvptx-increase-local-alignment",
+INITIALIZE_PASS(NVPTXIncreaseLocalAlignmentLegacyPass,
+                "nvptx-increase-local-alignment",
                 "Increase alignment for statically sized alloca arrays", false,
                 false)
 

``````````

</details>


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


More information about the llvm-commits mailing list