1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[C++11] Add NArySCEV->Operands iterator range

llvm-svn: 208158
This commit is contained in:
Tobias Grosser 2014-05-07 06:07:47 +00:00
parent 3be6b384b7
commit 8128149f4a
2 changed files with 11 additions and 8 deletions

View File

@ -14,6 +14,7 @@
#ifndef LLVM_ANALYSIS_SCALAREVOLUTIONEXPRESSIONS_H
#define LLVM_ANALYSIS_SCALAREVOLUTIONEXPRESSIONS_H
#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Support/ErrorHandling.h"
@ -151,8 +152,12 @@ namespace llvm {
}
typedef const SCEV *const *op_iterator;
typedef iterator_range<op_iterator> op_range;
op_iterator op_begin() const { return Operands; }
op_iterator op_end() const { return Operands + NumOperands; }
op_range operands() const {
return make_range(op_begin(), op_end());
}
Type *getType() const { return getOperand(0)->getType(); }

View File

@ -1098,11 +1098,10 @@ static const SCEV *getPreStartForSignExtend(const SCEVAddRecExpr *AR,
// subtraction is expensive. For this purpose, perform a quick and dirty
// difference, by checking for Step in the operand list.
SmallVector<const SCEV *, 4> DiffOps;
for (SCEVAddExpr::op_iterator I = SA->op_begin(), E = SA->op_end();
I != E; ++I) {
if (*I != Step)
DiffOps.push_back(*I);
}
for (const SCEV *Op : SA->operands())
if (Op != Step)
DiffOps.push_back(Op);
if (DiffOps.size() == SA->getNumOperands())
return nullptr;
@ -1341,9 +1340,8 @@ const SCEV *ScalarEvolution::getAnyExtendExpr(const SCEV *Op,
// Force the cast to be folded into the operands of an addrec.
if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(Op)) {
SmallVector<const SCEV *, 4> Ops;
for (SCEVAddRecExpr::op_iterator I = AR->op_begin(), E = AR->op_end();
I != E; ++I)
Ops.push_back(getAnyExtendExpr(*I, Ty));
for (const SCEV *Op : AR->operands())
Ops.push_back(getAnyExtendExpr(Op, Ty));
return getAddRecExpr(Ops, AR->getLoop(), SCEV::FlagNW);
}