@@ -1251,10 +1251,10 @@ LogicalResult SimpleAffineExprFlattener::visitMulExpr(AffineBinaryOpExpr expr) {
1251
1251
}
1252
1252
1253
1253
// 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
+
1258
1258
return success ();
1259
1259
}
1260
1260
@@ -1323,12 +1323,12 @@ LogicalResult SimpleAffineExprFlattener::visitModExpr(AffineBinaryOpExpr expr) {
1323
1323
// the GCD of expr and c.
1324
1324
SmallVector<int64_t , 8 > floorDividend (lhs);
1325
1325
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 ));
1328
1328
// Simplify the numerator and the denominator.
1329
1329
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);
1332
1332
}
1333
1333
int64_t floorDivisor = rhsConst / static_cast <int64_t >(gcd);
1334
1334
@@ -1442,12 +1442,12 @@ LogicalResult SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
1442
1442
// Simplify the floordiv, ceildiv if possible by canceling out the greatest
1443
1443
// common divisors of the numerator and denominator.
1444
1444
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 ));
1447
1447
// Simplify the numerator and the denominator.
1448
1448
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);
1451
1451
}
1452
1452
int64_t divisor = rhsConst / static_cast <int64_t >(gcd);
1453
1453
// If the divisor becomes 1, the updated LHS is the result. (The
0 commit comments