[PM] Move the LoopInfo analysis pointer into the InstCombiner class

along with the other analyses.

The most obvious reason why is because eventually I need to separate out
the pass layer from the rest of the instcombiner. However, it is also
probably a compile time win as every query through the pass manager
layer is pretty slow these days.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226550 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2015-01-20 08:35:24 +00:00
parent 7e9f120130
commit 06df574f20
2 changed files with 9 additions and 4 deletions

View File

@ -12,6 +12,7 @@
#include "InstCombineWorklist.h" #include "InstCombineWorklist.h"
#include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/TargetFolder.h" #include "llvm/Analysis/TargetFolder.h"
#include "llvm/Analysis/ValueTracking.h" #include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Dominators.h" #include "llvm/IR/Dominators.h"
@ -100,6 +101,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner
const DataLayout *DL; const DataLayout *DL;
TargetLibraryInfo *TLI; TargetLibraryInfo *TLI;
DominatorTree *DT; DominatorTree *DT;
LoopInfo *LI;
bool MadeIRChange; bool MadeIRChange;
LibCallSimplifier *Simplifier; LibCallSimplifier *Simplifier;
bool MinimizeSize; bool MinimizeSize;
@ -115,7 +117,8 @@ public:
static char ID; // Pass identification, replacement for typeid static char ID; // Pass identification, replacement for typeid
InstCombiner() InstCombiner()
: FunctionPass(ID), DL(nullptr), DT(nullptr), Builder(nullptr) { : FunctionPass(ID), DL(nullptr), DT(nullptr), LI(nullptr),
Builder(nullptr) {
MinimizeSize = false; MinimizeSize = false;
initializeInstCombinerPass(*PassRegistry::getPassRegistry()); initializeInstCombinerPass(*PassRegistry::getPassRegistry());
} }
@ -133,6 +136,8 @@ public:
DominatorTree *getDominatorTree() const { return DT; } DominatorTree *getDominatorTree() const { return DT; }
LoopInfo *getLoopInfo() const { return LI; }
TargetLibraryInfo *getTargetLibraryInfo() const { return TLI; } TargetLibraryInfo *getTargetLibraryInfo() const { return TLI; }
// Visitation implementation - Implement instruction combining for different // Visitation implementation - Implement instruction combining for different

View File

@ -799,9 +799,7 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
// If the incoming non-constant value is in I's block, we will remove one // If the incoming non-constant value is in I's block, we will remove one
// instruction, but insert another equivalent one, leading to infinite // instruction, but insert another equivalent one, leading to infinite
// instcombine. // instcombine.
auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>(); if (isPotentiallyReachable(I.getParent(), NonConstBB, DT, LI))
if (isPotentiallyReachable(I.getParent(), NonConstBB, DT,
LIWP ? &LIWP->getLoopInfo() : nullptr))
return nullptr; return nullptr;
} }
@ -2975,6 +2973,8 @@ bool InstCombiner::runOnFunction(Function &F) {
DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>(); DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
DL = DLP ? &DLP->getDataLayout() : nullptr; DL = DLP ? &DLP->getDataLayout() : nullptr;
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(); TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
// Minimizing size? // Minimizing size?