[llvm] [LoopReduceMotion] Improve loop by extract reduction instruction (PR #179215)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 03:38:18 PST 2026


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 origin/main HEAD --extensions cpp,h -- llvm/include/llvm/Transforms/Vectorize/LoopReduceMotion.h llvm/lib/Transforms/Vectorize/LoopReduceMotion.cpp llvm/lib/Passes/PassBuilder.cpp llvm/lib/Passes/PassBuilderPipelines.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopReduceMotion.cpp b/llvm/lib/Transforms/Vectorize/LoopReduceMotion.cpp
index 7a80e3e5a..3d64b7a5b 100644
--- a/llvm/lib/Transforms/Vectorize/LoopReduceMotion.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopReduceMotion.cpp
@@ -65,7 +65,8 @@ bool LoopReduceMotionPass::compareCost(LoopStandardAnalysisResults &AR, Loop &L,
 
   uint64_t FixedTripCount = SE->getSmallConstantTripCount(&L);
   if (FixedTripCount > 0) {
-    InstructionCost beforeCost = FixedTripCount * (ReduceAddCost + ScalarAddCost);
+    InstructionCost beforeCost =
+        FixedTripCount * (ReduceAddCost + ScalarAddCost);
     InstructionCost afterCost = FixedTripCount * VectorAddCost + ReduceAddCost;
 
     return afterCost < beforeCost;

``````````

</details>


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


More information about the llvm-commits mailing list