14 #define DEBUG_TYPE "loop-instsimplify"
29 STATISTIC(NumSimplified,
"Number of redundant instructions simplified");
32 class LoopInstSimplify :
public LoopPass {
55 "Simplify instructions in loops",
false,
false)
64 return new LoopInstSimplify();
70 const DataLayout *
TD = getAnalysisIfAvailable<DataLayout>();
95 while (!VisitStack.
empty()) {
98 bool IsSubloopHeader = Item.getInt();
107 if (!ToSimplify->empty() && !ToSimplify->count(I))
113 if (V && LI->replacementPreservesLCSSAForm(I, V)) {
117 Next->insert(cast<Instruction>(*UI));
126 if (IsSubloopHeader && !isa<PHINode>(I))
137 if (!Visited.
insert(SuccBB))
140 const Loop *SuccLoop = LI->getLoopFor(SuccBB);
141 if (SuccLoop && SuccLoop->
getHeader() == SuccBB
143 VisitStack.
push_back(WorklistItem(SuccBB,
true));
148 for (
unsigned i = 0; i < SubLoopExitBlocks.
size(); ++i) {
150 if (LI->getLoopFor(ExitBB) == L && Visited.
insert(ExitBB))
151 VisitStack.
push_back(WorklistItem(ExitBB,
false));
157 bool IsExitBlock = std::binary_search(ExitBlocks.begin(),
158 ExitBlocks.end(), SuccBB);
162 VisitStack.
push_back(WorklistItem(SuccBB,
false));
171 Changed |= LocalChanged;
172 }
while (LocalChanged);
void push_back(const T &Elt)
AnalysisUsage & addPreserved()
static PassRegistry * getPassRegistry()
STATISTIC(NumSimplified,"Number of redundant instructions simplified")
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=0)
BlockT * getHeader() const
LoopInfoBase< BlockT, LoopT > * LI
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val()
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
ID
LLVM Calling Convention Representation.
void getExitBlocks(SmallVectorImpl< BlockT * > &ExitBlocks) const
Interval::succ_iterator succ_begin(Interval *I)
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
AnalysisUsage & addPreservedID(const void *ID)
Pass * createLoopInstSimplifyPass()
void replaceAllUsesWith(Value *V)
Interval::succ_iterator succ_end(Interval *I)
void array_pod_sort(IteratorTy Start, IteratorTy End)
LLVM Basic Block Representation.
bool contains(const LoopT *L) const
Value * SimplifyInstruction(Instruction *I, const DataLayout *TD=0, const TargetLibraryInfo *TLI=0, const DominatorTree *DT=0)
void getUniqueExitBlocks(SmallVectorImpl< BasicBlock * > &ExitBlocks) const
loop Simplify instructions in loops
AnalysisUsage & addRequiredID(const void *ID)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
INITIALIZE_PASS_BEGIN(LoopInstSimplify,"loop-instsimplify","Simplify instructions in loops", false, false) INITIALIZE_PASS_END(LoopInstSimplify
Combine redundant instructions
loop Simplify instructions in false
LLVM Value Representation.
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD
void initializeLoopInstSimplifyPass(PassRegistry &)