forked from OSchip/llvm-project
[NFC] Factor out getOrCreateAddRecExpr method
llvm-svn: 344227
This commit is contained in:
parent
3368643f5e
commit
5dbeff3e1c
|
@ -1833,6 +1833,10 @@ private:
|
|||
const SCEV *getOrCreateMulExpr(SmallVectorImpl<const SCEV *> &Ops,
|
||||
SCEV::NoWrapFlags Flags);
|
||||
|
||||
// Get addrec expr already created or create a new one.
|
||||
const SCEV *getOrCreateAddRecExpr(SmallVectorImpl<const SCEV *> &Ops,
|
||||
const Loop *L, SCEV::NoWrapFlags Flags);
|
||||
|
||||
/// Return x if \p Val is f(x) where f is a 1-1 function.
|
||||
const SCEV *stripInjectiveFunctions(const SCEV *Val) const;
|
||||
|
||||
|
|
|
@ -2758,6 +2758,29 @@ ScalarEvolution::getOrCreateAddExpr(SmallVectorImpl<const SCEV *> &Ops,
|
|||
return S;
|
||||
}
|
||||
|
||||
const SCEV *
|
||||
ScalarEvolution::getOrCreateAddRecExpr(SmallVectorImpl<const SCEV *> &Ops,
|
||||
const Loop *L, SCEV::NoWrapFlags Flags) {
|
||||
FoldingSetNodeID ID;
|
||||
ID.AddInteger(scAddRecExpr);
|
||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
|
||||
ID.AddPointer(Ops[i]);
|
||||
ID.AddPointer(L);
|
||||
void *IP = nullptr;
|
||||
SCEVAddRecExpr *S =
|
||||
static_cast<SCEVAddRecExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
|
||||
if (!S) {
|
||||
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
|
||||
std::uninitialized_copy(Ops.begin(), Ops.end(), O);
|
||||
S = new (SCEVAllocator)
|
||||
SCEVAddRecExpr(ID.Intern(SCEVAllocator), O, Ops.size(), L);
|
||||
UniqueSCEVs.InsertNode(S, IP);
|
||||
addToLoopUseLists(S);
|
||||
}
|
||||
S->setNoWrapFlags(Flags);
|
||||
return S;
|
||||
}
|
||||
|
||||
const SCEV *
|
||||
ScalarEvolution::getOrCreateMulExpr(SmallVectorImpl<const SCEV *> &Ops,
|
||||
SCEV::NoWrapFlags Flags) {
|
||||
|
@ -3408,24 +3431,7 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
|
|||
|
||||
// Okay, it looks like we really DO need an addrec expr. Check to see if we
|
||||
// already have one, otherwise create a new one.
|
||||
FoldingSetNodeID ID;
|
||||
ID.AddInteger(scAddRecExpr);
|
||||
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
|
||||
ID.AddPointer(Operands[i]);
|
||||
ID.AddPointer(L);
|
||||
void *IP = nullptr;
|
||||
SCEVAddRecExpr *S =
|
||||
static_cast<SCEVAddRecExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
|
||||
if (!S) {
|
||||
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Operands.size());
|
||||
std::uninitialized_copy(Operands.begin(), Operands.end(), O);
|
||||
S = new (SCEVAllocator) SCEVAddRecExpr(ID.Intern(SCEVAllocator),
|
||||
O, Operands.size(), L);
|
||||
UniqueSCEVs.InsertNode(S, IP);
|
||||
addToLoopUseLists(S);
|
||||
}
|
||||
S->setNoWrapFlags(Flags);
|
||||
return S;
|
||||
return getOrCreateAddRecExpr(Operands, L, Flags);
|
||||
}
|
||||
|
||||
const SCEV *
|
||||
|
|
Loading…
Reference in New Issue