[llvm] [Analysis] Use range-based for loops (NFC) (PR #103540)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 20:46:36 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/103540
None
>From ac39a86f96250e0a388e74706b5f924ef4eae8ad Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 13 Aug 2024 20:40:57 -0700
Subject: [PATCH] [Analysis] Use range-based for loops (NFC)
---
llvm/lib/Analysis/DependenceAnalysis.cpp | 3 +--
llvm/lib/Analysis/ScalarEvolution.cpp | 8 ++++----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 8e44d548cb56f2..a4a98ea0bae146 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -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);
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 9a568a252f8d27..8aa73d9256835f 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -6664,8 +6664,8 @@ 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),
+ 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));
@@ -6673,8 +6673,8 @@ const ConstantRange &ScalarEvolution::getRangeRef(
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));
}
More information about the llvm-commits
mailing list