Skip to content

Commit fb4113e

Browse files
committed
[Passes] Remove legacy LoopUnswitch pass.
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
1 parent 6c44e39 commit fb4113e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+12
-6174
lines changed

llvm/include/llvm-c/Transforms/Scalar.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM);
9494
/** See llvm::createLoopUnrollAndJamPass function. */
9595
void LLVMAddLoopUnrollAndJamPass(LLVMPassManagerRef PM);
9696

97-
/** See llvm::createLoopUnswitchPass function. */
98-
void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM);
99-
10097
/** See llvm::createLowerAtomicPass function. */
10198
void LLVMAddLowerAtomicPass(LLVMPassManagerRef PM);
10299

llvm/include/llvm/LinkAllPasses.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ namespace {
133133
(void) llvm::createLoopRerollPass();
134134
(void) llvm::createLoopUnrollPass();
135135
(void) llvm::createLoopUnrollAndJamPass();
136-
(void) llvm::createLoopUnswitchPass();
137136
(void) llvm::createLoopVersioningLICMPass();
138137
(void) llvm::createLoopIdiomPass();
139138
(void) llvm::createLoopRotatePass();

llvm/include/llvm/Transforms/Scalar.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,6 @@ FunctionPass *createLoopFlattenPass();
169169
//
170170
Pass *createLoopStrengthReducePass();
171171

172-
//===----------------------------------------------------------------------===//
173-
//
174-
// LoopUnswitch - This pass is a simple loop unswitching pass.
175-
//
176-
Pass *createLoopUnswitchPass(bool OptimizeForSize = false,
177-
bool hasBranchDivergence = false);
178-
179172
//===----------------------------------------------------------------------===//
180173
//
181174
// LoopInstSimplify - This pass simplifies instructions in a loop's body.

llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ static cl::opt<bool>
130130
cl::Hidden,
131131
cl::desc("Disable shrink-wrap library calls"));
132132

133-
static cl::opt<bool> EnableSimpleLoopUnswitch(
134-
"enable-simple-loop-unswitch", cl::init(false), cl::Hidden,
135-
cl::desc("Enable the simple loop unswitch pass. Also enables independent "
136-
"cleanup passes integrated into the loop pass manager pipeline."));
137-
138133
cl::opt<bool>
139134
EnableGVNSink("enable-gvn-sink", cl::init(false), cl::ZeroOrMore,
140135
cl::desc("Enable the GVN sinking pass (default = off)"));
@@ -382,13 +377,13 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
382377
MPM.add(createVectorCombinePass());
383378

384379
// Begin the loop pass pipeline.
385-
if (EnableSimpleLoopUnswitch) {
386-
// The simple loop unswitch pass relies on separate cleanup passes. Schedule
387-
// them first so when we re-process a loop they run before other loop
388-
// passes.
389-
MPM.add(createLoopInstSimplifyPass());
390-
MPM.add(createLoopSimplifyCFGPass());
391-
}
380+
381+
// The simple loop unswitch pass relies on separate cleanup passes. Schedule
382+
// them first so when we re-process a loop they run before other loop
383+
// passes.
384+
MPM.add(createLoopInstSimplifyPass());
385+
MPM.add(createLoopSimplifyCFGPass());
386+
392387
// Try to remove as much code from the loop header as possible,
393388
// to reduce amount of IR that will have to be duplicated. However,
394389
// do not perform speculative hoisting the first time as LICM
@@ -402,10 +397,7 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
402397
// TODO: Investigate promotion cap for O1.
403398
MPM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap,
404399
/*AllowSpeculation=*/true));
405-
if (EnableSimpleLoopUnswitch)
406-
MPM.add(createSimpleLoopUnswitchLegacyPass());
407-
else
408-
MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3, DivergentTarget));
400+
MPM.add(createSimpleLoopUnswitchLegacyPass(OptLevel == 3));
409401
// FIXME: We break the loop pass pipeline here in order to do full
410402
// simplifycfg. Eventually loop-simplifycfg should be enhanced to replace the
411403
// need for this.
@@ -528,7 +520,7 @@ void PassManagerBuilder::addVectorPasses(legacy::PassManagerBase &PM,
528520
PM.add(createInstructionCombiningPass());
529521
PM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap,
530522
/*AllowSpeculation=*/true));
531-
PM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3, DivergentTarget));
523+
PM.add(createSimpleLoopUnswitchLegacyPass());
532524
PM.add(createCFGSimplificationPass(
533525
SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
534526
PM.add(createInstructionCombiningPass());

llvm/lib/Transforms/Scalar/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ add_llvm_component_library(LLVMScalarOpts
4545
LoopStrengthReduce.cpp
4646
LoopUnrollPass.cpp
4747
LoopUnrollAndJamPass.cpp
48-
LoopUnswitch.cpp
4948
LoopVersioningLICM.cpp
5049
LowerAtomicPass.cpp
5150
LowerConstantIntrinsics.cpp

0 commit comments

Comments
 (0)