LLVM 20.0.0git
|
#include "llvm/Transforms/Scalar/LoopSimplifyCFG.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopIterator.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include <optional>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "loop-simplifycfg" |
Functions | |
STATISTIC (NumTerminatorsFolded, "Number of terminators folded to unconditional branches") | |
STATISTIC (NumLoopBlocksDeleted, "Number of loop blocks deleted") | |
STATISTIC (NumLoopExitsDeleted, "Number of loop exiting edges deleted") | |
static BasicBlock * | getOnlyLiveSuccessor (BasicBlock *BB) |
If BB is a switch or a conditional branch, but only one of its successors can be reached from this block in runtime, return this successor. | |
static void | removeBlockFromLoops (BasicBlock *BB, Loop *FirstLoop, Loop *LastLoop=nullptr) |
Removes BB from all loops from [FirstLoop, LastLoop) in parent chain. | |
static Loop * | getInnermostLoopFor (SmallPtrSetImpl< BasicBlock * > &BBs, Loop &L, LoopInfo &LI) |
Find innermost loop that contains at least one block from BBs and contains the header of loop L . | |
static bool | constantFoldTerminators (Loop &L, DominatorTree &DT, LoopInfo &LI, ScalarEvolution &SE, MemorySSAUpdater *MSSAU, bool &IsLoopDeleted) |
Turn branches and switches with known constant conditions into unconditional branches. | |
static bool | mergeBlocksIntoPredecessors (Loop &L, DominatorTree &DT, LoopInfo &LI, MemorySSAUpdater *MSSAU, ScalarEvolution &SE) |
static bool | simplifyLoopCFG (Loop &L, DominatorTree &DT, LoopInfo &LI, ScalarEvolution &SE, MemorySSAUpdater *MSSAU, bool &IsLoopDeleted) |
Variables | |
static cl::opt< bool > | EnableTermFolding ("enable-loop-simplifycfg-term-folding", cl::init(true)) |
#define DEBUG_TYPE "loop-simplifycfg" |
Definition at line 35 of file LoopSimplifyCFG.cpp.
|
static |
Turn branches and switches with known constant conditions into unconditional branches.
Definition at line 642 of file LoopSimplifyCFG.cpp.
References EnableTermFolding.
Referenced by simplifyLoopCFG().
|
static |
Find innermost loop that contains at least one block from BBs
and contains the header of loop L
.
Definition at line 89 of file LoopSimplifyCFG.cpp.
References llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getLoopDepth(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), and llvm::LoopBase< BlockT, LoopT >::getParentLoop().
|
static |
If BB
is a switch or a conditional branch, but only one of its successors can be reached from this block in runtime, return this successor.
Otherwise, return nullptr.
Definition at line 50 of file LoopSimplifyCFG.cpp.
References Cond, llvm::Instruction::getSuccessor(), and llvm::BasicBlock::getTerminator().
|
static |
Definition at line 660 of file LoopSimplifyCFG.cpp.
References llvm::Block, Blocks, llvm::ScalarEvolution::forgetBlockAndLoopDispositions(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::MemorySSAUpdater::getMemorySSA(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getSingleSuccessor(), llvm::MergeBlockIntoPredecessor(), llvm::MemorySSA::verifyMemorySSA(), and llvm::VerifyMemorySSA.
Referenced by llvm::VPlanTransforms::createAndOptimizeReplicateRegions(), llvm::VPlanTransforms::optimize(), and simplifyLoopCFG().
|
static |
Removes BB
from all loops from [FirstLoop, LastLoop) in parent chain.
Definition at line 77 of file LoopSimplifyCFG.cpp.
References assert(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getHeader(), and llvm::LoopBase< BlockT, LoopT >::getParentLoop().
|
static |
Definition at line 695 of file LoopSimplifyCFG.cpp.
References constantFoldTerminators(), llvm::ScalarEvolution::forgetTopmostLoop(), and mergeBlocksIntoPredecessors().
Referenced by llvm::LoopSimplifyCFGPass::run().
STATISTIC | ( | NumLoopBlocksDeleted | , |
"Number of loop blocks deleted" | |||
) |
STATISTIC | ( | NumLoopExitsDeleted | , |
"Number of loop exiting edges deleted" | |||
) |
STATISTIC | ( | NumTerminatorsFolded | , |
"Number of terminators folded to unconditional branches" | |||
) |
|
static |
Referenced by constantFoldTerminators().