[PATCH] D37679: [IRCE][NFC] Introduce parameters for making lightweight IRCE
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 03:14:48 PDT 2017
mkazantsev updated this revision to Diff 114559.
https://reviews.llvm.org/D37679
Files:
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
Index: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
===================================================================
--- lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
+++ lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
@@ -199,7 +199,10 @@
class InductiveRangeCheckElimination : public LoopPass {
public:
static char ID;
- InductiveRangeCheckElimination() : LoopPass(ID) {
+ InductiveRangeCheckElimination(bool AllowPreLoopInsertion = true,
+ bool AllowPostLoopInsertion = true)
+ : LoopPass(ID), AllowPreLoopInsertion(AllowPreLoopInsertion),
+ AllowPostLoopInsertion(AllowPostLoopInsertion) {
initializeInductiveRangeCheckEliminationPass(
*PassRegistry::getPassRegistry());
}
@@ -210,6 +213,13 @@
}
bool runOnLoop(Loop *L, LPPassManager &LPM) override;
+
+private:
+ // Whether or not this pass run allows inserting of pre- and postloop. In case
+ // if either of them is not allowed but required, the whole transform gets
+ // rejected.
+ bool AllowPreLoopInsertion;
+ bool AllowPostLoopInsertion;
};
char InductiveRangeCheckElimination::ID = 0;
@@ -644,14 +654,21 @@
// for a definition)
LoopStructure MainLoopStructure;
+ // Whether or not we are allowed to insert pre- and postloop constraining.
+ bool AllowPreLoopInsertion;
+ bool AllowPostLoopInsertion;
+
public:
LoopConstrainer(Loop &L, LoopInfo &LI, LPPassManager &LPM,
const LoopStructure &LS, ScalarEvolution &SE,
- DominatorTree &DT, InductiveRangeCheck::Range R)
+ DominatorTree &DT, InductiveRangeCheck::Range R,
+ bool AllowPreLoopInsertion, bool AllowPostLoopInsertion)
: F(*L.getHeader()->getParent()), Ctx(L.getHeader()->getContext()),
SE(SE), DT(DT), LPM(LPM), LI(LI), OriginalLoop(L),
LatchTakenCount(nullptr), OriginalPreheader(nullptr),
- MainLoopPreheader(nullptr), Range(R), MainLoopStructure(LS) {}
+ MainLoopPreheader(nullptr), Range(R), MainLoopStructure(LS),
+ AllowPreLoopInsertion(AllowPreLoopInsertion),
+ AllowPostLoopInsertion(AllowPostLoopInsertion) {}
// Entry point for the algorithm. Returns true on success.
bool run();
@@ -1473,6 +1490,19 @@
bool NeedsPostLoop =
Increasing ? SR.HighLimit.hasValue() : SR.LowLimit.hasValue();
+ // Check if we have prohibited insertion of pre- and postloop explicitly.
+ if (NeedsPreLoop && !AllowPreLoopInsertion) {
+ DEBUG(dbgs() << "irce: could not insert a preloop because it was explicitly"
+ << " prohibited\n");
+ return false;
+ }
+
+ if (NeedsPostLoop && !AllowPostLoopInsertion) {
+ DEBUG(dbgs() << "irce: could not insert a postloop because it was"
+ << " explicitly prohibited\n");
+ return false;
+ }
+
Value *ExitPreLoopAt = nullptr;
Value *ExitMainLoopAt = nullptr;
const SCEVConstant *MinusOneS =
@@ -1763,7 +1793,8 @@
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
LoopConstrainer LC(*L, getAnalysis<LoopInfoWrapperPass>().getLoopInfo(), LPM,
- LS, SE, DT, SafeIterRange.getValue());
+ LS, SE, DT, SafeIterRange.getValue(),
+ AllowPreLoopInsertion, AllowPostLoopInsertion);
bool Changed = LC.run();
if (Changed) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37679.114559.patch
Type: text/x-patch
Size: 3386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170911/dd5f3d2b/attachment.bin>
More information about the llvm-commits
mailing list