[PATCH] D135387: [LoopPeel] Allow to bypass profitability checks. NFC
Anna Thomas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 6 11:57:38 PDT 2022
anna created this revision.
anna added reviewers: fhahn, skatkov.
Herald added a subscriber: hiraditya.
Herald added a project: All.
anna requested review of this revision.
Herald added a project: LLVM.
canPeel API checks legality as well as profitability of peeling the
loop. Separate this out since sometimes (for example downstream), we
just need to know if we can peel the loop.
Currently, since we have exactly one profitability check, it seems
unnecessary to have a separate API for this. So, we just decide based on
the passed in argument.
This is an NFC, since by default we always check profitability.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D135387
Files:
llvm/include/llvm/Transforms/Utils/LoopPeel.h
llvm/lib/Transforms/Utils/LoopPeel.cpp
Index: llvm/lib/Transforms/Utils/LoopPeel.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -75,7 +75,7 @@
static const char *PeeledCountMetaData = "llvm.loop.peeled.count";
// Check whether we are capable of peeling this loop.
-bool llvm::canPeel(Loop *L) {
+bool llvm::canPeel(Loop *L, const bool CheckPeelProfitability) {
// Make sure the loop is in simplified form
if (!L->isLoopSimplifyForm())
return false;
@@ -94,6 +94,10 @@
SmallVector<BasicBlock *, 4> Exits;
L->getUniqueNonLatchExitBlocks(Exits);
+ // All legality checks are done.
+ if (!CheckPeelProfitability)
+ return true;
+
// The latch must either be the only exiting block or all non-latch exit
// blocks have either a deopt or unreachable terminator or compose a chain of
// blocks where the last one is either deopt or unreachable terminated. Both
Index: llvm/include/llvm/Transforms/Utils/LoopPeel.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/LoopPeel.h
+++ llvm/include/llvm/Transforms/Utils/LoopPeel.h
@@ -18,7 +18,8 @@
namespace llvm {
-bool canPeel(Loop *L);
+// We do the profitability checks for loop peeling under CheckPeelProfitability.
+bool canPeel(Loop *L, const bool CheckPeelProfitability = true);
bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE,
DominatorTree &DT, AssumptionCache *AC, bool PreserveLCSSA);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135387.465819.patch
Type: text/x-patch
Size: 1556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221006/fa80c698/attachment.bin>
More information about the llvm-commits
mailing list