[PATCH] D97747: [LoopUnrollRuntime] Add option to assume the non latch exit block to be predictable.
Whitney Tsang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 3 12:43:59 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG58d531fd6f04: [LoopUnrollRuntime] Add option to assume the non latch exit block to be (authored by Whitney).
Changed prior to commit:
https://reviews.llvm.org/D97747?vs=327848&id=327892#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97747/new/
https://reviews.llvm.org/D97747
Files:
llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
Index: llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -50,6 +50,9 @@
"unroll-runtime-multi-exit", cl::init(false), cl::Hidden,
cl::desc("Allow runtime unrolling for loops with multiple exits, when "
"epilog is generated"));
+static cl::opt<bool> UnrollRuntimeOtherExitPredictable(
+ "unroll-runtime-other-exit-predictable", cl::init(false), cl::Hidden,
+ cl::desc("Assume the non latch exit block to be predictable"));
/// Connect the unrolling prolog code to the original loop.
/// The unrolling prolog code contains code to execute the
@@ -493,12 +496,19 @@
if (ExitingBlocks.size() > 2)
return false;
+ // Allow unrolling of loops with no non latch exit blocks.
+ if (OtherExits.size() == 0)
+ return true;
+
// The second heuristic is that L has one exit other than the latchexit and
// that exit is a deoptimize block. We know that deoptimize blocks are rarely
// taken, which also implies the branch leading to the deoptimize block is
- // highly predictable.
+ // highly predictable. When UnrollRuntimeOtherExitPredictable is specified, we
+ // assume the other exit branch is predictable even if it has no deoptimize
+ // call.
return (OtherExits.size() == 1 &&
- OtherExits[0]->getTerminatingDeoptimizeCall());
+ (UnrollRuntimeOtherExitPredictable ||
+ OtherExits[0]->getTerminatingDeoptimizeCall()));
// TODO: These can be fine-tuned further to consider code size or deopt states
// that are captured by the deoptimize exit block.
// Also, we can extend this to support more cases, if we actually
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97747.327892.patch
Type: text/x-patch
Size: 1785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210303/fe1a6be4/attachment.bin>
More information about the llvm-commits
mailing list