Addressed more comments

GitOrigin-RevId: a8b79d116a153415ae3f4afc9b401b09a074daed
diff --git a/lib/Analysis/AffineStructures.cpp b/lib/Analysis/AffineStructures.cpp
index 1252a73..4ed33de 100644
--- a/lib/Analysis/AffineStructures.cpp
+++ b/lib/Analysis/AffineStructures.cpp
@@ -1922,7 +1922,7 @@
 /// `pos1^th` local identifier. This function is intended to be used to remove
 /// redundancy when local variables at position `pos1` and `pos2` are restricted
 /// to have the same value.
-static void eleminateRedundantLocalId(FlatAffineConstraints &fac, unsigned pos1,
+static void eliminateRedundantLocalId(FlatAffineConstraints &fac, unsigned pos1,
                                       unsigned pos2) {
 
   assert(pos1 < fac.getNumLocalIds() && "Invalid local id position");
@@ -1983,24 +1983,24 @@
   // that can be merged, are merged.
   unsigned localOffset = getIdKindOffset(IdKind::Local);
   for (unsigned i = 0; i < divs1.size(); ++i) {
-    // Check if division representations exists `i^th` local id.
+    // Check if a division representation exists for the `i^th` local id.
     if (denoms1[i] == 0)
       continue;
     // Check if a division exists which is a duplicate of the division at `i`.
     for (unsigned j = i + 1; j < divs1.size(); ++j) {
-      // Check if division representations exists for `j^th` local id.
+      // Check if a division representation exists for the `j^th` local id.
       if (denoms1[j] == 0)
         continue;
       // Check if the denominators match.
       if (denoms1[i] != denoms1[j])
         continue;
       // Check if the representations are equal.
-      if (!std::equal(divs1[i].begin(), divs1[i].end(), divs1[j].begin()))
+      if (divs1[i] != divs1[j])
         continue;
 
       // Merge divisions at position `j` into division at position `i`.
-      eleminateRedundantLocalId(fac1, i, j);
-      eleminateRedundantLocalId(fac2, i, j);
+      eliminateRedundantLocalId(fac1, i, j);
+      eliminateRedundantLocalId(fac2, i, j);
       for (unsigned k = 0, g = divs1.size(); k < g; ++k) {
         SmallVector<int64_t, 8> &div = divs1[k];
         if (denoms1[k] != 0) {
@@ -2011,6 +2011,7 @@
 
       divs1.erase(divs1.begin() + j);
       denoms1.erase(denoms1.begin() + j);
+      // Since `j` can never be zero, we do not need to worry about overflows.
       --j;
     }
   }
diff --git a/unittests/Analysis/AffineStructuresTest.cpp b/unittests/Analysis/AffineStructuresTest.cpp
index 3117483..497816a 100644
--- a/unittests/Analysis/AffineStructuresTest.cpp
+++ b/unittests/Analysis/AffineStructuresTest.cpp
@@ -882,11 +882,11 @@
   }
 
   {
-    // (x) : (exists y = [x / 2], z = [x + y / 3], z = [z + 1 / 5]: y + z >= x).
+    // (x) : (exists y = [x / 2], z = [x + y / 3], w = [z + 1 / 5]: y + z >= x).
     FlatAffineConstraints fac1(1);
     fac1.addLocalFloorDiv({1, 0}, 2);       // y = [x / 2].
     fac1.addLocalFloorDiv({1, 1, 0}, 3);    // z = [x + y / 3].
-    fac1.addLocalFloorDiv({0, 0, 1, 1}, 5); // z = [z + 1 / 5].
+    fac1.addLocalFloorDiv({0, 0, 1, 1}, 5); // w = [z + 1 / 5].
     fac1.addInequality({-1, 1, 1, 0, 0});   // y + z >= x.
 
     // (x) : (exists y = [x / 2], z = [x + y / 3], w = [z + 1 / 5]: y + z <= x).
@@ -911,13 +911,13 @@
   {
     // (x) : (exists y = [x + 1 / 3], z = [x + 2 / 3]: y + z >= x).
     FlatAffineConstraints fac1(1);
-    fac1.addLocalFloorDiv({1, 1}, 2);    // y = [x + 1 / 3].
+    fac1.addLocalFloorDiv({1, 1}, 2);    // y = [x + 1 / 2].
     fac1.addLocalFloorDiv({1, 0, 2}, 3); // z = [x + 2 / 3].
     fac1.addInequality({-1, 1, 1, 0});   // y + z >= x.
 
     // (x) : (exists y = [x + 1 / 3], z = [x + 2 / 3]: y + z <= x).
     FlatAffineConstraints fac2(1);
-    fac2.addLocalFloorDiv({1, 1}, 2);    // y = [x + 1 / 3].
+    fac2.addLocalFloorDiv({1, 1}, 2);    // y = [x + 1 / 2].
     fac2.addLocalFloorDiv({1, 0, 2}, 3); // z = [x + 2 / 3].
     fac2.addInequality({1, -1, -1, 0});  // y + z <= x.