diff options
author | Florian Hahn <flo@fhahn.com> | 2025-01-27 21:20:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-27 21:20:04 +0000 |
commit | ad9da92cf6f735747ef04fd56937e1d76819e503 (patch) | |
tree | a4a125b517dbf7c835609b59f84107146ca6fee4 /llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp | |
parent | 804b81d39f2d50743fd2090aed72dad29f5fb388 (diff) | |
download | llvm-ad9da92cf6f735747ef04fd56937e1d76819e503.zip llvm-ad9da92cf6f735747ef04fd56937e1d76819e503.tar.gz llvm-ad9da92cf6f735747ef04fd56937e1d76819e503.tar.bz2 |
[LoopUnroll] Add RuntimeUnrollMultiExit to loop unroll options (NFC) (#124462)
Add an extra knob to RuntimeUnrollMultiExit to let backends control
whether to allow multi-exit unrolling on a per-loop basis.
This gives backends more fine-grained control on deciding if multi-exit
unrolling is profitable for a given loop and uarch. Similar to
4226e0a0c75.
PR: https://github.com/llvm/llvm-project/pull/124462
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp index b0bc55c..524b268 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp @@ -461,7 +461,7 @@ CloneLoopBlocks(Loop *L, Value *NewIter, const bool UseEpilogRemainder, /// 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 canProfitablyUnrollMultiExitLoop( +static bool canProfitablyRuntimeUnrollMultiExitLoop( Loop *L, SmallVectorImpl<BasicBlock *> &OtherExits, BasicBlock *LatchExit, bool UseEpilogRemainder) { @@ -583,7 +583,8 @@ bool llvm::UnrollRuntimeLoopRemainder( bool UseEpilogRemainder, bool UnrollRemainder, bool ForgetAllSCEV, LoopInfo *LI, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC, const TargetTransformInfo *TTI, bool PreserveLCSSA, - unsigned SCEVExpansionBudget, Loop **ResultLoop) { + unsigned SCEVExpansionBudget, bool RuntimeUnrollMultiExit, + Loop **ResultLoop) { LLVM_DEBUG(dbgs() << "Trying runtime unrolling on Loop: \n"); LLVM_DEBUG(L->dump()); LLVM_DEBUG(UseEpilogRemainder ? dbgs() << "Using epilog remainder.\n" @@ -632,8 +633,9 @@ bool llvm::UnrollRuntimeLoopRemainder( if (!PreserveLCSSA) return false; - if (!canProfitablyUnrollMultiExitLoop(L, OtherExits, LatchExit, - UseEpilogRemainder)) { + if (!RuntimeUnrollMultiExit && + !canProfitablyRuntimeUnrollMultiExitLoop(L, OtherExits, LatchExit, + UseEpilogRemainder)) { LLVM_DEBUG( dbgs() << "Multiple exit/exiting blocks in loop and multi-exit unrolling not " |