[llvm] [LoopUnroll] Introduce parallel reduction phis when unrolling. (PR #149470)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 25 06:55:52 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/include/llvm/Analysis/TargetTransformInfo.h llvm/include/llvm/Transforms/Utils/UnrollLoop.h llvm/lib/Transforms/Utils/LoopUnroll.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index 7810c26a6..4d7db1712 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -109,9 +109,9 @@ UnrollVerifyLoopInfo("unroll-verify-loopinfo", cl::Hidden,
 #endif
                     );
 
-static cl::opt<bool>
-UnrollAddParallelReductions("unroll-add-parallel-reductions", cl::init(false), cl::Hidden,
-                    cl::desc("Allow unrolling to add parallel reduction phis."));
+static cl::opt<bool> UnrollAddParallelReductions(
+    "unroll-add-parallel-reductions", cl::init(false), cl::Hidden,
+    cl::desc("Allow unrolling to add parallel reduction phis."));
 
 /// Check if unrolling created a situation where we need to insert phi nodes to
 /// preserve LCSSA form.
@@ -670,8 +670,9 @@ llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
   // restricting to single-block loops where the unrolled iterations are known
   // to not exit.
   DenseMap<PHINode *, RecurrenceDescriptor> Reductions;
-  bool CanAddAdditionalAccumulators = UnrollAddParallelReductions &&
-      !CompletelyUnroll && L->getNumBlocks() == 1 &&
+  bool CanAddAdditionalAccumulators =
+      UnrollAddParallelReductions && !CompletelyUnroll &&
+      L->getNumBlocks() == 1 &&
       (ULO.Runtime ||
        (ExitInfos.contains(Header) && ((ExitInfos[Header].TripCount != 0 &&
                                         ExitInfos[Header].BreakoutTrip == 0))));

``````````

</details>


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


More information about the llvm-commits mailing list