[LIR] Move all the helpers to be private and re-order the methods in

a way that groups things logically. No functionality changed.

llvm-svn: 244845
This commit is contained in:
Chandler Carruth 2015-08-13 00:10:03 +00:00
parent ea366a34fc
commit 1c383505c5

View File

@ -129,20 +129,6 @@ public:
}
bool runOnLoop(Loop *L, LPPassManager &LPM) override;
bool runOnLoopBlock(BasicBlock *BB, const SCEV *BECount,
SmallVectorImpl<BasicBlock *> &ExitBlocks);
bool processLoopStore(StoreInst *SI, const SCEV *BECount);
bool processLoopMemSet(MemSetInst *MSI, const SCEV *BECount);
bool processLoopStridedStore(Value *DestPtr, unsigned StoreSize,
unsigned StoreAlignment, Value *SplatValue,
Instruction *TheStore, const SCEVAddRecExpr *Ev,
const SCEV *BECount);
bool processLoopStoreOfLoopLoad(StoreInst *SI, unsigned StoreSize,
const SCEVAddRecExpr *StoreEv,
const SCEVAddRecExpr *LoadEv,
const SCEV *BECount);
/// This transformation requires natural loop information & requires that
/// loop preheaders be inserted into the CFG.
@ -189,8 +175,32 @@ public:
Loop *getLoop() const { return CurLoop; }
private:
bool runOnNoncountableLoop();
/// \name Countable Loop Idiom Handling
/// @{
bool runOnCountableLoop();
bool runOnLoopBlock(BasicBlock *BB, const SCEV *BECount,
SmallVectorImpl<BasicBlock *> &ExitBlocks);
bool processLoopStore(StoreInst *SI, const SCEV *BECount);
bool processLoopMemSet(MemSetInst *MSI, const SCEV *BECount);
bool processLoopStridedStore(Value *DestPtr, unsigned StoreSize,
unsigned StoreAlignment, Value *SplatValue,
Instruction *TheStore, const SCEVAddRecExpr *Ev,
const SCEV *BECount);
bool processLoopStoreOfLoopLoad(StoreInst *SI, unsigned StoreSize,
const SCEVAddRecExpr *StoreEv,
const SCEVAddRecExpr *LoadEv,
const SCEV *BECount);
/// @}
/// \name Noncountable Loop Idiom Handling
/// @{
bool runOnNoncountableLoop();
/// @}
};
} // End anonymous namespace.
@ -552,7 +562,6 @@ CallInst *NclPopcountRecognize::createPopcntIntrinsic(IRBuilderTy &IRBuilder,
/// detected, transform the relevant code to popcount intrinsic function
/// call, and return true; otherwise, return false.
bool NclPopcountRecognize::recognize() {
if (!LIR.getTargetTransformInfo())
return false;
@ -577,6 +586,28 @@ bool NclPopcountRecognize::recognize() {
//
//===----------------------------------------------------------------------===//
bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) {
if (skipOptnoneFunction(L))
return false;
CurLoop = L;
// If the loop could not be converted to canonical form, it must have an
// indirectbr in it, just give up.
if (!L->getLoopPreheader())
return false;
// Disable loop idiom recognition if the function's name is a common idiom.
StringRef Name = L->getHeader()->getParent()->getName();
if (Name == "memset" || Name == "memcpy")
return false;
SE = &getAnalysis<ScalarEvolution>();
if (SE->hasLoopInvariantBackedgeTakenCount(L))
return runOnCountableLoop();
return runOnNoncountableLoop();
}
bool LoopIdiomRecognize::runOnCountableLoop() {
const SCEV *BECount = SE->getBackedgeTakenCount(CurLoop);
assert(!isa<SCEVCouldNotCompute>(BECount) &&
@ -617,36 +648,6 @@ bool LoopIdiomRecognize::runOnCountableLoop() {
return MadeChange;
}
bool LoopIdiomRecognize::runOnNoncountableLoop() {
NclPopcountRecognize Popcount(*this);
if (Popcount.recognize())
return true;
return false;
}
bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) {
if (skipOptnoneFunction(L))
return false;
CurLoop = L;
// If the loop could not be converted to canonical form, it must have an
// indirectbr in it, just give up.
if (!L->getLoopPreheader())
return false;
// Disable loop idiom recognition if the function's name is a common idiom.
StringRef Name = L->getHeader()->getParent()->getName();
if (Name == "memset" || Name == "memcpy")
return false;
SE = &getAnalysis<ScalarEvolution>();
if (SE->hasLoopInvariantBackedgeTakenCount(L))
return runOnCountableLoop();
return runOnNoncountableLoop();
}
/// runOnLoopBlock - Process the specified block, which lives in a counted loop
/// with the specified backedge count. This block is known to be in the current
/// loop and not in any subloops.
@ -1062,3 +1063,11 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(
++NumMemCpy;
return true;
}
bool LoopIdiomRecognize::runOnNoncountableLoop() {
NclPopcountRecognize Popcount(*this);
if (Popcount.recognize())
return true;
return false;
}