[PATCH] D132208: [LoopIntWrapPredication] Loop Integer Wrapping Predication Pass

Sergei Kachkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 23 08:37:03 PDT 2022


kachkov98 added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopIntWrapPredication.cpp:246
+  BasicBlock *Preheader = L.getLoopPreheader();
+  assert(Preheader);
+  Instruction *Loc = Preheader->getTerminator();
----------------
craig.topper wrote:
> kachkov98 wrote:
> > craig.topper wrote:
> > > What guarantees the loop has a preheader? Placement in the pipeline would probably guarantee it but I'm not sure anything does when running the pass by itself. Unless I missed something.
> > Loop Pass Manager should run LoopSimplify pass, and this cannonical form ensures that loop has a preheader: https://llvm.org/docs/LoopTerminology.html#loop-simplify-form
> I agree that it works if run as part of the Loop Pass Manager. But if you run the pass standalone from the opt command line, it may not be in loop simplify form. The pass either needs to protect itself or require the LoopSimplify analysis.
I've tried to run only this pass from opt with -debug-pass-manager option, and this is the output:
```
Running pass: VerifierPass on [module]
Running analysis: VerifierAnalysis on [module]
Running analysis: InnerAnalysisManagerProxy<llvm::FunctionAnalysisManager, llvm::Module> on [module]
Running analysis: PreservedCFGCheckerAnalysis on foo
Running pass: LoopSimplifyPass on foo (14 instructions)
Running analysis: LoopAnalysis on foo
Running analysis: DominatorTreeAnalysis on foo
Running analysis: AssumptionAnalysis on foo
Running analysis: TargetIRAnalysis on foo
Running pass: LCSSAPass on foo (14 instructions)
Running analysis: AAManager on foo
Running analysis: TargetLibraryAnalysis on foo
Running analysis: BasicAA on foo
Running analysis: ScopedNoAliasAA on foo
Running analysis: TypeBasedAA on foo
Running analysis: OuterAnalysisManagerProxy<llvm::ModuleAnalysisManager, llvm::Function> on foo
Running analysis: ScalarEvolutionAnalysis on foo
Running analysis: InnerAnalysisManagerProxy<llvm::LoopAnalysisManager, llvm::Function> on foo
Running pass: LoopIntWrapPredicationPass on Loop at depth 1 containing: %for.body<header><latch><exiting>
Invalidating analysis: PreservedCFGCheckerAnalysis on foo
Invalidating analysis: VerifierAnalysis on [module]
Running pass: VerifierPass on [module]
Running analysis: VerifierAnalysis on [module]
Running pass: PrintModulePass on [module]
```
So LoopSimplify pass is launched even in standalone mode as a part of loop pass manager pipeline.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132208/new/

https://reviews.llvm.org/D132208



More information about the llvm-commits mailing list