Skip to content

Commit 7718ac3

Browse files
authored
[MLIR] NFC. Fix remaining clang-tidy warnings in AffineExpr.cpp (#80933)
NFC. Fix remaining clang-tidy warnings in AffineExpr.cpp.
1 parent d42f395 commit 7718ac3

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

mlir/lib/IR/AffineExpr.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,10 +1251,10 @@ LogicalResult SimpleAffineExprFlattener::visitMulExpr(AffineBinaryOpExpr expr) {
12511251
}
12521252

12531253
// Get the RHS constant.
1254-
auto rhsConst = rhs[getConstantIndex()];
1255-
for (unsigned i = 0, e = lhs.size(); i < e; i++) {
1256-
lhs[i] *= rhsConst;
1257-
}
1254+
int64_t rhsConst = rhs[getConstantIndex()];
1255+
for (int64_t &lhsElt : lhs)
1256+
lhsElt *= rhsConst;
1257+
12581258
return success();
12591259
}
12601260

@@ -1323,12 +1323,12 @@ LogicalResult SimpleAffineExprFlattener::visitModExpr(AffineBinaryOpExpr expr) {
13231323
// the GCD of expr and c.
13241324
SmallVector<int64_t, 8> floorDividend(lhs);
13251325
uint64_t gcd = rhsConst;
1326-
for (unsigned i = 0, e = lhs.size(); i < e; i++)
1327-
gcd = std::gcd(gcd, (uint64_t)std::abs(lhs[i]));
1326+
for (int64_t lhsElt : lhs)
1327+
gcd = std::gcd(gcd, (uint64_t)std::abs(lhsElt));
13281328
// Simplify the numerator and the denominator.
13291329
if (gcd != 1) {
1330-
for (unsigned i = 0, e = floorDividend.size(); i < e; i++)
1331-
floorDividend[i] = floorDividend[i] / static_cast<int64_t>(gcd);
1330+
for (int64_t &floorDividendElt : floorDividend)
1331+
floorDividendElt = floorDividendElt / static_cast<int64_t>(gcd);
13321332
}
13331333
int64_t floorDivisor = rhsConst / static_cast<int64_t>(gcd);
13341334

@@ -1442,12 +1442,12 @@ LogicalResult SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
14421442
// Simplify the floordiv, ceildiv if possible by canceling out the greatest
14431443
// common divisors of the numerator and denominator.
14441444
uint64_t gcd = std::abs(rhsConst);
1445-
for (unsigned i = 0, e = lhs.size(); i < e; i++)
1446-
gcd = std::gcd(gcd, (uint64_t)std::abs(lhs[i]));
1445+
for (int64_t lhsElt : lhs)
1446+
gcd = std::gcd(gcd, (uint64_t)std::abs(lhsElt));
14471447
// Simplify the numerator and the denominator.
14481448
if (gcd != 1) {
1449-
for (unsigned i = 0, e = lhs.size(); i < e; i++)
1450-
lhs[i] = lhs[i] / static_cast<int64_t>(gcd);
1449+
for (int64_t &lhsElt : lhs)
1450+
lhsElt = lhsElt / static_cast<int64_t>(gcd);
14511451
}
14521452
int64_t divisor = rhsConst / static_cast<int64_t>(gcd);
14531453
// If the divisor becomes 1, the updated LHS is the result. (The

0 commit comments

Comments
 (0)