Skip to content

Commit

Permalink
[Passes] Remove legacy LoopUnswitch pass.
Browse files Browse the repository at this point in the history
The legacy LoopUnswitch pass is only used in the legacy pass manager
pipeline, which is deprecated.

The NewPM replacement is SimpleLoopUnswitch and I think it is time to
remove the legacy LoopUnswitch code.

Fixes #31000.

Reviewed By: aeubanks, Meinersbur, asbirlea

Differential Revision: https://reviews.llvm.org/D124376
  • Loading branch information
fhahn committed Apr 29, 2022
1 parent 6c44e39 commit fb4113e
Show file tree
Hide file tree
Showing 62 changed files with 12 additions and 6,174 deletions.
3 changes: 0 additions & 3 deletions llvm/include/llvm-c/Transforms/Scalar.h
Expand Up @@ -94,9 +94,6 @@ void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM);
/** See llvm::createLoopUnrollAndJamPass function. */
void LLVMAddLoopUnrollAndJamPass(LLVMPassManagerRef PM);

/** See llvm::createLoopUnswitchPass function. */
void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM);

/** See llvm::createLowerAtomicPass function. */
void LLVMAddLowerAtomicPass(LLVMPassManagerRef PM);

Expand Down
1 change: 0 additions & 1 deletion llvm/include/llvm/LinkAllPasses.h
Expand Up @@ -133,7 +133,6 @@ namespace {
(void) llvm::createLoopRerollPass();
(void) llvm::createLoopUnrollPass();
(void) llvm::createLoopUnrollAndJamPass();
(void) llvm::createLoopUnswitchPass();
(void) llvm::createLoopVersioningLICMPass();
(void) llvm::createLoopIdiomPass();
(void) llvm::createLoopRotatePass();
Expand Down
7 changes: 0 additions & 7 deletions llvm/include/llvm/Transforms/Scalar.h
Expand Up @@ -169,13 +169,6 @@ FunctionPass *createLoopFlattenPass();
//
Pass *createLoopStrengthReducePass();

//===----------------------------------------------------------------------===//
//
// LoopUnswitch - This pass is a simple loop unswitching pass.
//
Pass *createLoopUnswitchPass(bool OptimizeForSize = false,
bool hasBranchDivergence = false);

//===----------------------------------------------------------------------===//
//
// LoopInstSimplify - This pass simplifies instructions in a loop's body.
Expand Down
26 changes: 9 additions & 17 deletions llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Expand Up @@ -130,11 +130,6 @@ static cl::opt<bool>
cl::Hidden,
cl::desc("Disable shrink-wrap library calls"));

static cl::opt<bool> EnableSimpleLoopUnswitch(
"enable-simple-loop-unswitch", cl::init(false), cl::Hidden,
cl::desc("Enable the simple loop unswitch pass. Also enables independent "
"cleanup passes integrated into the loop pass manager pipeline."));

cl::opt<bool>
EnableGVNSink("enable-gvn-sink", cl::init(false), cl::ZeroOrMore,
cl::desc("Enable the GVN sinking pass (default = off)"));
Expand Down Expand Up @@ -382,13 +377,13 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
MPM.add(createVectorCombinePass());

// Begin the loop pass pipeline.
if (EnableSimpleLoopUnswitch) {
// The simple loop unswitch pass relies on separate cleanup passes. Schedule
// them first so when we re-process a loop they run before other loop
// passes.
MPM.add(createLoopInstSimplifyPass());
MPM.add(createLoopSimplifyCFGPass());
}

// The simple loop unswitch pass relies on separate cleanup passes. Schedule
// them first so when we re-process a loop they run before other loop
// passes.
MPM.add(createLoopInstSimplifyPass());
MPM.add(createLoopSimplifyCFGPass());

// Try to remove as much code from the loop header as possible,
// to reduce amount of IR that will have to be duplicated. However,
// do not perform speculative hoisting the first time as LICM
Expand All @@ -402,10 +397,7 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
// TODO: Investigate promotion cap for O1.
MPM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/true));
if (EnableSimpleLoopUnswitch)
MPM.add(createSimpleLoopUnswitchLegacyPass());
else
MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3, DivergentTarget));
MPM.add(createSimpleLoopUnswitchLegacyPass(OptLevel == 3));
// FIXME: We break the loop pass pipeline here in order to do full
// simplifycfg. Eventually loop-simplifycfg should be enhanced to replace the
// need for this.
Expand Down Expand Up @@ -528,7 +520,7 @@ void PassManagerBuilder::addVectorPasses(legacy::PassManagerBase &PM,
PM.add(createInstructionCombiningPass());
PM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/true));
PM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3, DivergentTarget));
PM.add(createSimpleLoopUnswitchLegacyPass());
PM.add(createCFGSimplificationPass(
SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
PM.add(createInstructionCombiningPass());
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Transforms/Scalar/CMakeLists.txt
Expand Up @@ -45,7 +45,6 @@ add_llvm_component_library(LLVMScalarOpts
LoopStrengthReduce.cpp
LoopUnrollPass.cpp
LoopUnrollAndJamPass.cpp
LoopUnswitch.cpp
LoopVersioningLICM.cpp
LowerAtomicPass.cpp
LowerConstantIntrinsics.cpp
Expand Down

0 comments on commit fb4113e

Please sign in to comment.