diff options
author | Florian Hahn <flo@fhahn.com> | 2025-09-18 19:25:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-18 19:25:05 +0100 |
commit | 50b9ca4ddaea08fc72b7dcba1390c1689eed9a17 (patch) | |
tree | 5590ac002ff19458dad1cfef10c0862f2a72cd86 /llvm/lib/Transforms/Utils/LoopUtils.cpp | |
parent | a858c9071c25826d7d60af420e4dcf9106bf7cc0 (diff) | |
download | llvm-50b9ca4ddaea08fc72b7dcba1390c1689eed9a17.zip llvm-50b9ca4ddaea08fc72b7dcba1390c1689eed9a17.tar.gz llvm-50b9ca4ddaea08fc72b7dcba1390c1689eed9a17.tar.bz2 |
[VPlan] Simplify Plan's entry in removeBranchOnConst. (#154510)
After https://github.com/llvm/llvm-project/pull/153643, there may be a
BranchOnCond with constant condition in the entry block.
Simplify those in removeBranchOnConst. This removes a number of
redundant conditional branch from entry blocks.
In some cases, it may also make the original scalar loop unreachable,
because we know it will never execute. In that case, we need to remove
the loop from LoopInfo, because all unreachable blocks may dominate each
other, making LoopInfo invalid. In those cases, we can also completely
remove the loop, for which I'll share a follow-up patch.
Depends on https://github.com/llvm/llvm-project/pull/153643.
PR: https://github.com/llvm/llvm-project/pull/154510
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUtils.cpp | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 7b1a7ce..b6ba822 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -1865,32 +1865,6 @@ int llvm::rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI, return NumReplaced; } -/// Set weights for \p UnrolledLoop and \p RemainderLoop based on weights for -/// \p OrigLoop. -void llvm::setProfileInfoAfterUnrolling(Loop *OrigLoop, Loop *UnrolledLoop, - Loop *RemainderLoop, uint64_t UF) { - assert(UF > 0 && "Zero unrolled factor is not supported"); - assert(UnrolledLoop != RemainderLoop && - "Unrolled and Remainder loops are expected to distinct"); - - // Get number of iterations in the original scalar loop. - unsigned OrigLoopInvocationWeight = 0; - std::optional<unsigned> OrigAverageTripCount = - getLoopEstimatedTripCount(OrigLoop, &OrigLoopInvocationWeight); - if (!OrigAverageTripCount) - return; - - // Calculate number of iterations in unrolled loop. - unsigned UnrolledAverageTripCount = *OrigAverageTripCount / UF; - // Calculate number of iterations for remainder loop. - unsigned RemainderAverageTripCount = *OrigAverageTripCount % UF; - - setLoopEstimatedTripCount(UnrolledLoop, UnrolledAverageTripCount, - OrigLoopInvocationWeight); - setLoopEstimatedTripCount(RemainderLoop, RemainderAverageTripCount, - OrigLoopInvocationWeight); -} - /// Utility that implements appending of loops onto a worklist. /// Loops are added in preorder (analogous for reverse postorder for trees), /// and the worklist is processed LIFO. |