diff --git a/include/llvm/IR/Operator.h b/include/llvm/IR/Operator.h index 46c1dfc3e73..d0bce742cc9 100644 --- a/include/llvm/IR/Operator.h +++ b/include/llvm/IR/Operator.h @@ -488,6 +488,14 @@ public: inline op_iterator idx_end() { return op_end(); } inline const_op_iterator idx_end() const { return op_end(); } + inline iterator_range indices() { + return make_range(idx_begin(), idx_end()); + } + + inline iterator_range indices() const { + return make_range(idx_begin(), idx_end()); + } + Value *getPointerOperand() { return getOperand(0); } @@ -544,7 +552,7 @@ public: } unsigned countNonConstantIndices() const { - return count_if(make_range(idx_begin(), idx_end()), [](const Use& use) { + return count_if(indices(), [](const Use& use) { return !isa(*use); }); } diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 843c04855bf..221b116d437 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -5732,8 +5732,8 @@ const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) { return getUnknown(GEP); SmallVector IndexExprs; - for (auto Index = GEP->idx_begin(); Index != GEP->idx_end(); ++Index) - IndexExprs.push_back(getSCEV(*Index)); + for (Value *Index : GEP->indices()) + IndexExprs.push_back(getSCEV(Index)); return getGEPExpr(GEP, IndexExprs); }