LLVM
15.0.0git
include
llvm
Transforms
Utils
LoopSimplify.h
Go to the documentation of this file.
1
//===- LoopSimplify.h - Loop Canonicalization Pass --------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This pass performs several transformations to transform natural loops into a
10
// simpler form, which makes subsequent analyses and transformations simpler and
11
// more effective.
12
//
13
// Loop pre-header insertion guarantees that there is a single, non-critical
14
// entry edge from outside of the loop to the loop header. This simplifies a
15
// number of analyses and transformations, such as LICM.
16
//
17
// Loop exit-block insertion guarantees that all exit blocks from the loop
18
// (blocks which are outside of the loop that have predecessors inside of the
19
// loop) only have predecessors from inside of the loop (and are thus dominated
20
// by the loop header). This simplifies transformations such as store-sinking
21
// that are built into LICM.
22
//
23
// This pass also guarantees that loops will have exactly one backedge.
24
//
25
// Indirectbr instructions introduce several complications. If the loop
26
// contains or is entered by an indirectbr instruction, it may not be possible
27
// to transform the loop and make these guarantees. Client code should check
28
// that these conditions are true before relying on them.
29
//
30
// Note that the simplifycfg pass will clean up blocks which are split out but
31
// end up being unnecessary, so usage of this pass should not pessimize
32
// generated code.
33
//
34
// This pass obviously modifies the CFG, but updates loop information and
35
// dominator information.
36
//
37
//===----------------------------------------------------------------------===//
38
#ifndef LLVM_TRANSFORMS_UTILS_LOOPSIMPLIFY_H
39
#define LLVM_TRANSFORMS_UTILS_LOOPSIMPLIFY_H
40
41
#include "
llvm/IR/PassManager.h
"
42
43
namespace
llvm
{
44
45
class
AssumptionCache;
46
class
DominatorTree;
47
class
Loop;
48
class
LoopInfo;
49
class
MemorySSAUpdater;
50
class
ScalarEvolution;
51
52
/// This pass is responsible for loop canonicalization.
53
class
LoopSimplifyPass
:
public
PassInfoMixin
<LoopSimplifyPass> {
54
public
:
55
PreservedAnalyses
run
(
Function
&
F
,
FunctionAnalysisManager
&AM);
56
};
57
58
/// Simplify each loop in a loop nest recursively.
59
///
60
/// This takes a potentially un-simplified loop L (and its children) and turns
61
/// it into a simplified loop nest with preheaders and single backedges. It will
62
/// update \c DominatorTree, \c LoopInfo, \c ScalarEvolution and \c MemorySSA
63
/// analyses if they're non-null, and LCSSA if \c PreserveLCSSA is true.
64
bool
simplifyLoop
(
Loop
*L,
DominatorTree
*DT,
LoopInfo
*LI,
ScalarEvolution
*SE,
65
AssumptionCache
*AC,
MemorySSAUpdater
*MSSAU,
66
bool
PreserveLCSSA);
67
68
}
// end namespace llvm
69
70
#endif // LLVM_TRANSFORMS_UTILS_LOOPSIMPLIFY_H
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:
PassManager.h:152
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:17
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition:
PassManager.h:371
llvm::Function
Definition:
Function.h:60
llvm::Loop
Represents a single loop in the control flow graph.
Definition:
LoopInfo.h:530
llvm::ScalarEvolution
The main scalar evolution driver.
Definition:
ScalarEvolution.h:449
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition:
Dominators.h:166
F
#define F(x, y, z)
Definition:
MD5.cpp:55
llvm::LoopSimplifyPass
This pass is responsible for loop canonicalization.
Definition:
LoopSimplify.h:53
llvm::MemorySSAUpdater
Definition:
MemorySSAUpdater.h:54
llvm::LoopInfo
Definition:
LoopInfo.h:1086
llvm::AssumptionCache
A cache of @llvm.assume calls within a function.
Definition:
AssumptionCache.h:42
PassManager.h
llvm::simplifyLoop
bool simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, MemorySSAUpdater *MSSAU, bool PreserveLCSSA)
Simplify each loop in a loop nest recursively.
Definition:
LoopSimplify.cpp:713
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:
InstructionSimplify.h:42
llvm::LoopSimplifyPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition:
LoopSimplify.cpp:832
Generated on Mon May 16 2022 16:16:41 for LLVM by
1.8.17