[SCEV] Add interface for constructing generic SCEVComparePredicate [NFC}
This commit is contained in:
parent
b71eed7e8f
commit
83f895d952
|
@ -1167,6 +1167,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
const SCEVPredicate *getEqualPredicate(const SCEV *LHS, const SCEV *RHS);
|
const SCEVPredicate *getEqualPredicate(const SCEV *LHS, const SCEV *RHS);
|
||||||
|
const SCEVPredicate *getComparePredicate(ICmpInst::Predicate Pred,
|
||||||
|
const SCEV *LHS, const SCEV *RHS);
|
||||||
|
|
||||||
const SCEVPredicate *
|
const SCEVPredicate *
|
||||||
getWrapPredicate(const SCEVAddRecExpr *AR,
|
getWrapPredicate(const SCEVAddRecExpr *AR,
|
||||||
|
|
|
@ -13537,19 +13537,25 @@ void ScalarEvolutionWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
|
|
||||||
const SCEVPredicate *ScalarEvolution::getEqualPredicate(const SCEV *LHS,
|
const SCEVPredicate *ScalarEvolution::getEqualPredicate(const SCEV *LHS,
|
||||||
const SCEV *RHS) {
|
const SCEV *RHS) {
|
||||||
|
return getComparePredicate(ICmpInst::ICMP_EQ, LHS, RHS);
|
||||||
|
}
|
||||||
|
|
||||||
|
const SCEVPredicate *
|
||||||
|
ScalarEvolution::getComparePredicate(const ICmpInst::Predicate Pred,
|
||||||
|
const SCEV *LHS, const SCEV *RHS) {
|
||||||
FoldingSetNodeID ID;
|
FoldingSetNodeID ID;
|
||||||
assert(LHS->getType() == RHS->getType() &&
|
assert(LHS->getType() == RHS->getType() &&
|
||||||
"Type mismatch between LHS and RHS");
|
"Type mismatch between LHS and RHS");
|
||||||
// Unique this node based on the arguments
|
// Unique this node based on the arguments
|
||||||
ID.AddInteger(SCEVPredicate::P_Compare);
|
ID.AddInteger(SCEVPredicate::P_Compare);
|
||||||
ID.AddInteger(ICmpInst::ICMP_EQ);
|
ID.AddInteger(Pred);
|
||||||
ID.AddPointer(LHS);
|
ID.AddPointer(LHS);
|
||||||
ID.AddPointer(RHS);
|
ID.AddPointer(RHS);
|
||||||
void *IP = nullptr;
|
void *IP = nullptr;
|
||||||
if (const auto *S = UniquePreds.FindNodeOrInsertPos(ID, IP))
|
if (const auto *S = UniquePreds.FindNodeOrInsertPos(ID, IP))
|
||||||
return S;
|
return S;
|
||||||
SCEVComparePredicate *Eq = new (SCEVAllocator)
|
SCEVComparePredicate *Eq = new (SCEVAllocator)
|
||||||
SCEVComparePredicate(ID.Intern(SCEVAllocator), ICmpInst::ICMP_EQ, LHS, RHS);
|
SCEVComparePredicate(ID.Intern(SCEVAllocator), Pred, LHS, RHS);
|
||||||
UniquePreds.InsertNode(Eq, IP);
|
UniquePreds.InsertNode(Eq, IP);
|
||||||
return Eq;
|
return Eq;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue