Skip to content

Commit

Permalink
[passes] Remove the legacy PM version of IRCE
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D148338
  • Loading branch information
bjope committed Apr 14, 2023
1 parent b74e89c commit 0b911a3
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 81 deletions.
1 change: 0 additions & 1 deletion llvm/include/llvm/InitializePasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ void initializeGuardWideningLegacyPassPass(PassRegistry&);
void initializeHardwareLoopsLegacyPass(PassRegistry&);
void initializeMIRProfileLoaderPassPass(PassRegistry &);
void initializeIPSCCPLegacyPassPass(PassRegistry&);
void initializeIRCELegacyPassPass(PassRegistry&);
void initializeIRSimilarityIdentifierWrapperPassPass(PassRegistry&);
void initializeIRTranslatorPass(PassRegistry&);
void initializeIVUsersWrapperPassPass(PassRegistry&);
Expand Down
1 change: 0 additions & 1 deletion llvm/include/llvm/LinkAllPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ namespace {
(void) llvm::createGlobalsAAWrapperPass();
(void) llvm::createGuardWideningPass();
(void) llvm::createLoopGuardWideningPass();
(void) llvm::createInductiveRangeCheckEliminationPass();
(void) llvm::createInstSimplifyLegacyPass();
(void) llvm::createInstructionCombiningPass();
(void) llvm::createJMCInstrumenterPass();
Expand Down
7 changes: 0 additions & 7 deletions llvm/include/llvm/Transforms/Scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ Pass *createLoopGuardWideningPass();
//
FunctionPass *createSROAPass(bool PreserveCFG = true);

//===----------------------------------------------------------------------===//
//
// InductiveRangeCheckElimination - Transform loops to elide range checks on
// linear functions of the induction variable.
//
Pass *createInductiveRangeCheckEliminationPass();

//===----------------------------------------------------------------------===//
//
// LICM - This pass is a loop invariant code motion and memory promotion pass.
Expand Down
71 changes: 0 additions & 71 deletions llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
Expand Down Expand Up @@ -249,40 +247,8 @@ class InductiveRangeCheckElimination {
bool run(Loop *L, function_ref<void(Loop *, bool)> LPMAddNewLoop);
};

class IRCELegacyPass : public FunctionPass {
public:
static char ID;

IRCELegacyPass() : FunctionPass(ID) {
initializeIRCELegacyPassPass(*PassRegistry::getPassRegistry());
}

void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<BranchProbabilityInfoWrapperPass>();
AU.addRequired<DominatorTreeWrapperPass>();
AU.addPreserved<DominatorTreeWrapperPass>();
AU.addRequired<LoopInfoWrapperPass>();
AU.addPreserved<LoopInfoWrapperPass>();
AU.addRequired<ScalarEvolutionWrapperPass>();
AU.addPreserved<ScalarEvolutionWrapperPass>();
}

bool runOnFunction(Function &F) override;
};

} // end anonymous namespace

char IRCELegacyPass::ID = 0;

INITIALIZE_PASS_BEGIN(IRCELegacyPass, "irce",
"Inductive range check elimination", false, false)
INITIALIZE_PASS_DEPENDENCY(BranchProbabilityInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
INITIALIZE_PASS_END(IRCELegacyPass, "irce", "Inductive range check elimination",
false, false)

/// Parse a single ICmp instruction, `ICI`, into a range check. If `ICI` cannot
/// be interpreted as a range check, return false and set `Index` and `End`
/// to `nullptr`. Otherwise set `Index` to the SCEV being range checked, and
Expand Down Expand Up @@ -1826,39 +1792,6 @@ PreservedAnalyses IRCEPass::run(Function &F, FunctionAnalysisManager &AM) {
return getLoopPassPreservedAnalyses();
}

bool IRCELegacyPass::runOnFunction(Function &F) {
if (skipFunction(F))
return false;

ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
BranchProbabilityInfo &BPI =
getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
InductiveRangeCheckElimination IRCE(SE, &BPI, DT, LI);

bool Changed = false;

for (const auto &L : LI) {
Changed |= simplifyLoop(L, &DT, &LI, &SE, nullptr, nullptr,
/*PreserveLCSSA=*/false);
Changed |= formLCSSARecursively(*L, DT, &LI, &SE);
}

SmallPriorityWorklist<Loop *, 4> Worklist;
appendLoopsToWorklist(LI, Worklist);
auto LPMAddNewLoop = [&](Loop *NL, bool IsSubloop) {
if (!IsSubloop)
appendLoopsToWorklist(*NL, Worklist);
};

while (!Worklist.empty()) {
Loop *L = Worklist.pop_back_val();
Changed |= IRCE.run(L, LPMAddNewLoop);
}
return Changed;
}

bool
InductiveRangeCheckElimination::isProfitableToTransform(const Loop &L,
LoopStructure &LS) {
Expand Down Expand Up @@ -1998,7 +1931,3 @@ bool InductiveRangeCheckElimination::run(

return Changed;
}

Pass *llvm::createInductiveRangeCheckEliminationPass() {
return new IRCELegacyPass();
}
1 change: 0 additions & 1 deletion llvm/lib/Transforms/Scalar/Scalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
initializeEarlyCSEMemSSALegacyPassPass(Registry);
initializeMakeGuardsExplicitLegacyPassPass(Registry);
initializeFlattenCFGLegacyPassPass(Registry);
initializeIRCELegacyPassPass(Registry);
initializeInferAddressSpacesPass(Registry);
initializeInstSimplifyLegacyPassPass(Registry);
initializeLegacyLICMPassPass(Registry);
Expand Down

0 comments on commit 0b911a3

Please sign in to comment.