Skip to content

Commit

Permalink
Remove unnecessary const_cast
Browse files Browse the repository at this point in the history
llvm-svn: 302368
  • Loading branch information
sanjoy committed May 7, 2017
1 parent 40415ee commit df8c2eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/ScalarEvolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ class ScalarEvolution {
/// delinearization).
void findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,
SmallVectorImpl<const SCEV *> &Sizes,
const SCEV *ElementSize) const;
const SCEV *ElementSize);

void print(raw_ostream &OS) const;
void verify() const;
Expand Down
11 changes: 4 additions & 7 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9626,7 +9626,7 @@ const SCEV *ScalarEvolution::getElementSize(Instruction *Inst) {

void ScalarEvolution::findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,
SmallVectorImpl<const SCEV *> &Sizes,
const SCEV *ElementSize) const {
const SCEV *ElementSize) {
if (Terms.size() < 1 || !ElementSize)
return;

Expand All @@ -9650,13 +9650,11 @@ void ScalarEvolution::findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,
return numberOfTerms(LHS) > numberOfTerms(RHS);
});

ScalarEvolution &SE = *const_cast<ScalarEvolution *>(this);

// Try to divide all terms by the element size. If term is not divisible by
// element size, proceed with the original term.
for (const SCEV *&Term : Terms) {
const SCEV *Q, *R;
SCEVDivision::divide(SE, Term, ElementSize, &Q, &R);
SCEVDivision::divide(*this, Term, ElementSize, &Q, &R);
if (!Q->isZero())
Term = Q;
}
Expand All @@ -9665,7 +9663,7 @@ void ScalarEvolution::findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,

// Remove constant factors.
for (const SCEV *T : Terms)
if (const SCEV *NewT = removeConstantFactors(SE, T))
if (const SCEV *NewT = removeConstantFactors(*this, T))
NewTerms.push_back(NewT);

DEBUG({
Expand All @@ -9674,8 +9672,7 @@ void ScalarEvolution::findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,
dbgs() << *T << "\n";
});

if (NewTerms.empty() ||
!findArrayDimensionsRec(SE, NewTerms, Sizes)) {
if (NewTerms.empty() || !findArrayDimensionsRec(*this, NewTerms, Sizes)) {
Sizes.clear();
return;
}
Expand Down

0 comments on commit df8c2eb

Please sign in to comment.