Skip to content

Commit 1115dee

Browse files
[Analysis] Use range-based for loops (NFC) (#103540)
1 parent bd42177 commit 1115dee

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

llvm/lib/Analysis/DependenceAnalysis.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,8 +2450,7 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst,
24502450
const SCEVConstant *Constant = dyn_cast<SCEVConstant>(Delta);
24512451
if (const SCEVAddExpr *Sum = dyn_cast<SCEVAddExpr>(Delta)) {
24522452
// If Delta is a sum of products, we may be able to make further progress.
2453-
for (unsigned Op = 0, Ops = Sum->getNumOperands(); Op < Ops; Op++) {
2454-
const SCEV *Operand = Sum->getOperand(Op);
2453+
for (const SCEV *Operand : Sum->operands()) {
24552454
if (isa<SCEVConstant>(Operand)) {
24562455
assert(!Constant && "Surprised to find multiple constants");
24572456
Constant = cast<SCEVConstant>(Operand);

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6664,17 +6664,17 @@ const ConstantRange &ScalarEvolution::getRangeRef(
66646664
WrapType |= OBO::NoSignedWrap;
66656665
if (Add->hasNoUnsignedWrap())
66666666
WrapType |= OBO::NoUnsignedWrap;
6667-
for (unsigned i = 1, e = Add->getNumOperands(); i != e; ++i)
6668-
X = X.addWithNoWrap(getRangeRef(Add->getOperand(i), SignHint, Depth + 1),
6669-
WrapType, RangeType);
6667+
for (const SCEV *Op : drop_begin(Add->operands()))
6668+
X = X.addWithNoWrap(getRangeRef(Op, SignHint, Depth + 1), WrapType,
6669+
RangeType);
66706670
return setRange(Add, SignHint,
66716671
ConservativeResult.intersectWith(X, RangeType));
66726672
}
66736673
case scMulExpr: {
66746674
const SCEVMulExpr *Mul = cast<SCEVMulExpr>(S);
66756675
ConstantRange X = getRangeRef(Mul->getOperand(0), SignHint, Depth + 1);
6676-
for (unsigned i = 1, e = Mul->getNumOperands(); i != e; ++i)
6677-
X = X.multiply(getRangeRef(Mul->getOperand(i), SignHint, Depth + 1));
6676+
for (const SCEV *Op : drop_begin(Mul->operands()))
6677+
X = X.multiply(getRangeRef(Op, SignHint, Depth + 1));
66786678
return setRange(Mul, SignHint,
66796679
ConservativeResult.intersectWith(X, RangeType));
66806680
}

0 commit comments

Comments
 (0)