forked from OSchip/llvm-project
[SCEV] Return ArrayRef from getSCEVValues() (NFC)
Return a read-only view on this set. For the one internal use, directly access ExprValueMap.
This commit is contained in:
parent
51fdd802c7
commit
2d0fc3e46f
|
@ -1281,7 +1281,7 @@ private:
|
|||
DenseMap<const SCEV *, uint32_t> MinTrailingZerosCache;
|
||||
|
||||
/// Return the Value set from which the SCEV expr is generated.
|
||||
ValueSetVector *getSCEVValues(const SCEV *S);
|
||||
ArrayRef<Value *> getSCEVValues(const SCEV *S);
|
||||
|
||||
/// Private helper method for the GetMinTrailingZeros method
|
||||
uint32_t GetMinTrailingZerosImpl(const SCEV *S);
|
||||
|
|
|
@ -4280,11 +4280,10 @@ bool ScalarEvolution::containsAddRecurrence(const SCEV *S) {
|
|||
|
||||
/// Return the ValueOffsetPair set for \p S. \p S can be represented
|
||||
/// by the value and offset from any ValueOffsetPair in the set.
|
||||
ScalarEvolution::ValueSetVector *
|
||||
ScalarEvolution::getSCEVValues(const SCEV *S) {
|
||||
ArrayRef<Value *> ScalarEvolution::getSCEVValues(const SCEV *S) {
|
||||
ExprValueMapType::iterator SI = ExprValueMap.find_as(S);
|
||||
if (SI == ExprValueMap.end())
|
||||
return nullptr;
|
||||
return None;
|
||||
#ifndef NDEBUG
|
||||
if (VerifySCEVMap) {
|
||||
// Check there is no dangling Value in the set returned.
|
||||
|
@ -4292,7 +4291,7 @@ ScalarEvolution::getSCEVValues(const SCEV *S) {
|
|||
assert(ValueExprMap.count(V));
|
||||
}
|
||||
#endif
|
||||
return &SI->second;
|
||||
return SI->second.getArrayRef();
|
||||
}
|
||||
|
||||
/// Erase Value from ValueExprMap and ExprValueMap. ValueExprMap.erase(V)
|
||||
|
@ -4301,11 +4300,11 @@ ScalarEvolution::getSCEVValues(const SCEV *S) {
|
|||
void ScalarEvolution::eraseValueFromMap(Value *V) {
|
||||
ValueExprMapType::iterator I = ValueExprMap.find_as(V);
|
||||
if (I != ValueExprMap.end()) {
|
||||
const SCEV *S = I->second;
|
||||
// Remove V from the set of ExprValueMap[S]
|
||||
if (auto *SV = getSCEVValues(S))
|
||||
SV->remove(V);
|
||||
ValueExprMap.erase(V);
|
||||
auto EVIt = ExprValueMap.find(I->second);
|
||||
bool Removed = EVIt->second.remove(V);
|
||||
(void) Removed;
|
||||
assert(Removed && "Value not in ExprValueMap?");
|
||||
ValueExprMap.erase(I);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1872,17 +1872,17 @@ Value *SCEVExpander::expandCodeForImpl(const SCEV *SH, Type *Ty, bool Root) {
|
|||
|
||||
Value *SCEVExpander::FindValueInExprValueMap(const SCEV *S,
|
||||
const Instruction *InsertPt) {
|
||||
auto *Set = SE.getSCEVValues(S);
|
||||
ArrayRef<Value *> Set = SE.getSCEVValues(S);
|
||||
// If the expansion is not in CanonicalMode, and the SCEV contains any
|
||||
// sub scAddRecExpr type SCEV, it is required to expand the SCEV literally.
|
||||
if (CanonicalMode || !SE.containsAddRecurrence(S)) {
|
||||
// If S is scConstant, it may be worse to reuse an existing Value.
|
||||
if (S->getSCEVType() != scConstant && Set) {
|
||||
if (S->getSCEVType() != scConstant) {
|
||||
// Choose a Value from the set which dominates the InsertPt.
|
||||
// InsertPt should be inside the Value's parent loop so as not to break
|
||||
// the LCSSA form.
|
||||
for (Value *V : *Set) {
|
||||
Instruction *EntInst = dyn_cast_or_null<Instruction>(V);
|
||||
for (Value *V : Set) {
|
||||
Instruction *EntInst = dyn_cast<Instruction>(V);
|
||||
if (!EntInst)
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Reference in New Issue