SCEVExpander: give new insts a name that identifies the reponsible pass.

llvm-svn: 133992
This commit is contained in:
Andrew Trick 2011-06-28 05:07:32 +00:00
parent 60ab3efb3e
commit 411daa5e81
5 changed files with 14 additions and 9 deletions

View File

@ -30,6 +30,10 @@ namespace llvm {
/// memory. /// memory.
class SCEVExpander : public SCEVVisitor<SCEVExpander, Value*> { class SCEVExpander : public SCEVVisitor<SCEVExpander, Value*> {
ScalarEvolution &SE; ScalarEvolution &SE;
// New instructions receive a name to identifies them with the current pass.
const char* Label;
std::map<std::pair<const SCEV *, Instruction *>, AssertingVH<Value> > std::map<std::pair<const SCEV *, Instruction *>, AssertingVH<Value> >
InsertedExpressions; InsertedExpressions;
std::set<AssertingVH<Value> > InsertedValues; std::set<AssertingVH<Value> > InsertedValues;
@ -67,8 +71,8 @@ namespace llvm {
public: public:
/// SCEVExpander - Construct a SCEVExpander in "canonical" mode. /// SCEVExpander - Construct a SCEVExpander in "canonical" mode.
explicit SCEVExpander(ScalarEvolution &se) explicit SCEVExpander(ScalarEvolution &se, const char *label)
: SE(se), IVIncInsertLoop(0), CanonicalMode(true), : SE(se), Label(label), IVIncInsertLoop(0), CanonicalMode(true),
Builder(se.getContext(), TargetFolder(se.TD)) {} Builder(se.getContext(), TargetFolder(se.TD)) {}
/// clear - Erase the contents of the InsertedExpressions map so that users /// clear - Erase the contents of the InsertedExpressions map so that users

View File

@ -936,7 +936,8 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
BasicBlock *Header = L->getHeader(); BasicBlock *Header = L->getHeader();
Builder.SetInsertPoint(Header, Header->begin()); Builder.SetInsertPoint(Header, Header->begin());
pred_iterator HPB = pred_begin(Header), HPE = pred_end(Header); pred_iterator HPB = pred_begin(Header), HPE = pred_end(Header);
PHINode *PN = Builder.CreatePHI(ExpandTy, std::distance(HPB, HPE), "lsr.iv"); PHINode *PN = Builder.CreatePHI(ExpandTy, std::distance(HPB, HPE),
Twine(Label) + ".iv");
rememberInstruction(PN); rememberInstruction(PN);
// Create the step instructions and populate the PHI. // Create the step instructions and populate the PHI.
@ -972,8 +973,8 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
} }
} else { } else {
IncV = isNegative ? IncV = isNegative ?
Builder.CreateSub(PN, StepV, "lsr.iv.next") : Builder.CreateSub(PN, StepV, Twine(Label) + ".iv.next") :
Builder.CreateAdd(PN, StepV, "lsr.iv.next"); Builder.CreateAdd(PN, StepV, Twine(Label) + ".iv.next");
rememberInstruction(IncV); rememberInstruction(IncV);
} }
PN->addIncoming(IncV, Pred); PN->addIncoming(IncV, Pred);

View File

@ -1169,7 +1169,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L);
// Create a rewriter object which we'll use to transform the code with. // Create a rewriter object which we'll use to transform the code with.
SCEVExpander Rewriter(*SE); SCEVExpander Rewriter(*SE, "indvars");
// Eliminate redundant IV users. // Eliminate redundant IV users.
// //

View File

@ -467,7 +467,7 @@ processLoopStridedStore(Value *DestPtr, unsigned StoreSize,
// header. This allows us to insert code for it in the preheader. // header. This allows us to insert code for it in the preheader.
BasicBlock *Preheader = CurLoop->getLoopPreheader(); BasicBlock *Preheader = CurLoop->getLoopPreheader();
IRBuilder<> Builder(Preheader->getTerminator()); IRBuilder<> Builder(Preheader->getTerminator());
SCEVExpander Expander(*SE); SCEVExpander Expander(*SE, "loop-idiom");
// Okay, we have a strided store "p[i]" of a splattable value. We can turn // Okay, we have a strided store "p[i]" of a splattable value. We can turn
// this into a memset in the loop preheader now if we want. However, this // this into a memset in the loop preheader now if we want. However, this
@ -556,7 +556,7 @@ processLoopStoreOfLoopLoad(StoreInst *SI, unsigned StoreSize,
// header. This allows us to insert code for it in the preheader. // header. This allows us to insert code for it in the preheader.
BasicBlock *Preheader = CurLoop->getLoopPreheader(); BasicBlock *Preheader = CurLoop->getLoopPreheader();
IRBuilder<> Builder(Preheader->getTerminator()); IRBuilder<> Builder(Preheader->getTerminator());
SCEVExpander Expander(*SE); SCEVExpander Expander(*SE, "loop-idiom");
// Okay, we have a strided store "p[i]" of a loaded value. We can turn // Okay, we have a strided store "p[i]" of a loaded value. We can turn
// this into a memcpy in the loop preheader now if we want. However, this // this into a memcpy in the loop preheader now if we want. However, this

View File

@ -3698,7 +3698,7 @@ LSRInstance::ImplementSolution(const SmallVectorImpl<const Formula *> &Solution,
// we can remove them after we are done working. // we can remove them after we are done working.
SmallVector<WeakVH, 16> DeadInsts; SmallVector<WeakVH, 16> DeadInsts;
SCEVExpander Rewriter(SE); SCEVExpander Rewriter(SE, "lsr");
Rewriter.disableCanonicalMode(); Rewriter.disableCanonicalMode();
Rewriter.setIVIncInsertPos(L, IVIncInsertPos); Rewriter.setIVIncInsertPos(L, IVIncInsertPos);