[llvm] [LoopUnroll] Use branch probability in multi-exit loop unrolling (PR #164799)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 23 04:00:22 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 origin/main HEAD --extensions cpp -- llvm/lib/Transforms/Utils/LoopUnrollRuntime.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/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
index 520fd741e..c3ef587fd 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -527,7 +527,7 @@ computeBranchProbabilityUsingMetadata(BasicBlock *Src, BasicBlock *Dst) {
/// Returns true if we can profitably unroll the multi-exit loop L. Currently,
/// we return true only if UnrollRuntimeMultiExit is set to true.
static bool canProfitablyRuntimeUnrollMultiExitLoop(
- Loop *L, const TargetTransformInfo *TTI,
+ Loop *L, const TargetTransformInfo *TTI,
SmallVectorImpl<BasicBlock *> &OtherExits, BasicBlock *LatchExit,
bool UseEpilogRemainder) {
@@ -573,8 +573,8 @@ static bool canProfitablyRuntimeUnrollMultiExitLoop(
return UnrollRuntimeOtherExitPredictable || *BranchProb < Threshold;
}
}
-
- // We know that deoptimize blocks are rarely taken, which also implies the
+
+ // We know that deoptimize blocks are rarely taken, which also implies the
// branch leading to the deoptimize block is highly predictable. When
// UnrollRuntimeOtherExitPredictable is specified, we assume the other exit
// branch is predictable even if it has no deoptimize call.
@@ -720,9 +720,8 @@ bool llvm::UnrollRuntimeLoopRemainder(
// Otherwise perform multi-exit unrolling, if either the target indicates
// it is profitable or the general profitability heuristics apply.
if (!RuntimeUnrollMultiExit &&
- !canProfitablyRuntimeUnrollMultiExitLoop(L, TTI, OtherExits,
- LatchExit,
- UseEpilogRemainder)) {
+ !canProfitablyRuntimeUnrollMultiExitLoop(
+ L, TTI, OtherExits, LatchExit, UseEpilogRemainder)) {
LLVM_DEBUG(dbgs() << "Multiple exit/exiting blocks in loop and "
"multi-exit unrolling not enabled!\n");
return false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/164799
More information about the llvm-commits
mailing list