[Mlir-commits] [mlir] a36b73e - Apply clang-tidy fixes for modernize-loop-convert in Barvinok.cpp (NFC)

Mehdi Amini llvmlistbot at llvm.org
Mon Mar 4 23:15:24 PST 2024


Author: Mehdi Amini
Date: 2024-03-04T23:15:10-08:00
New Revision: a36b73e5a7f5b2f4b65f67544922be35bf81a67e

URL: https://github.com/llvm/llvm-project/commit/a36b73e5a7f5b2f4b65f67544922be35bf81a67e
DIFF: https://github.com/llvm/llvm-project/commit/a36b73e5a7f5b2f4b65f67544922be35bf81a67e.diff

LOG: Apply clang-tidy fixes for modernize-loop-convert in Barvinok.cpp (NFC)

Added: 
    

Modified: 
    mlir/lib/Analysis/Presburger/Barvinok.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/Presburger/Barvinok.cpp b/mlir/lib/Analysis/Presburger/Barvinok.cpp
index 4be81c25951b84..da45bdc6a978bd 100644
--- a/mlir/lib/Analysis/Presburger/Barvinok.cpp
+++ b/mlir/lib/Analysis/Presburger/Barvinok.cpp
@@ -613,10 +613,10 @@ void normalizeDenominatorExponents(int &sign, QuasiPolynomial &num,
   // denominator, and convert them to their absolute values.
   unsigned numNegExps = 0;
   Fraction sumNegExps(0, 1);
-  for (unsigned j = 0, e = dens.size(); j < e; ++j) {
-    if (dens[j] < 0) {
+  for (const auto &den : dens) {
+    if (den < 0) {
       numNegExps += 1;
-      sumNegExps += dens[j];
+      sumNegExps += den;
     }
   }
 
@@ -722,8 +722,8 @@ mlir::presburger::detail::computeNumTerms(const GeneratingFunction &gf) {
     // Then, using the formula for geometric series, we replace each (1 -
     // (s+1)^(dens[j])) with
     // (-s)(\sum_{0 ≤ k < dens[j]} (s+1)^k).
-    for (unsigned j = 0, e = dens.size(); j < e; ++j)
-      dens[j] = abs(dens[j]) - 1;
+    for (auto &j : dens)
+      j = abs(j) - 1;
     // Note that at this point, the semantics of `dens[j]` changes to mean
     // a term (\sum_{0 ≤ k ≤ dens[j]} (s+1)^k). The denominator is, as before,
     // a product of these terms.


        


More information about the Mlir-commits mailing list