Skip to content

Commit

Permalink
[Analysis] Use range-based for loops (NFC) (#103540)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata authored Aug 14, 2024
1 parent bd42177 commit 1115dee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Analysis/DependenceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2450,8 +2450,7 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst,
const SCEVConstant *Constant = dyn_cast<SCEVConstant>(Delta);
if (const SCEVAddExpr *Sum = dyn_cast<SCEVAddExpr>(Delta)) {
// If Delta is a sum of products, we may be able to make further progress.
for (unsigned Op = 0, Ops = Sum->getNumOperands(); Op < Ops; Op++) {
const SCEV *Operand = Sum->getOperand(Op);
for (const SCEV *Operand : Sum->operands()) {
if (isa<SCEVConstant>(Operand)) {
assert(!Constant && "Surprised to find multiple constants");
Constant = cast<SCEVConstant>(Operand);
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6664,17 +6664,17 @@ const ConstantRange &ScalarEvolution::getRangeRef(
WrapType |= OBO::NoSignedWrap;
if (Add->hasNoUnsignedWrap())
WrapType |= OBO::NoUnsignedWrap;
for (unsigned i = 1, e = Add->getNumOperands(); i != e; ++i)
X = X.addWithNoWrap(getRangeRef(Add->getOperand(i), SignHint, Depth + 1),
WrapType, RangeType);
for (const SCEV *Op : drop_begin(Add->operands()))
X = X.addWithNoWrap(getRangeRef(Op, SignHint, Depth + 1), WrapType,
RangeType);
return setRange(Add, SignHint,
ConservativeResult.intersectWith(X, RangeType));
}
case scMulExpr: {
const SCEVMulExpr *Mul = cast<SCEVMulExpr>(S);
ConstantRange X = getRangeRef(Mul->getOperand(0), SignHint, Depth + 1);
for (unsigned i = 1, e = Mul->getNumOperands(); i != e; ++i)
X = X.multiply(getRangeRef(Mul->getOperand(i), SignHint, Depth + 1));
for (const SCEV *Op : drop_begin(Mul->operands()))
X = X.multiply(getRangeRef(Op, SignHint, Depth + 1));
return setRange(Mul, SignHint,
ConservativeResult.intersectWith(X, RangeType));
}
Expand Down

0 comments on commit 1115dee

Please sign in to comment.