[PATCH] D80860: Exact integer emptiness checks for FlatAffineConstraints

Arjun P via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 5 09:30:01 PST 2022


arjunp added inline comments.


================
Comment at: mlir/lib/Analysis/Presburger/Simplex.cpp:131
+  for (unsigned col = 0; col < nCol; ++col)
+    tableau(row, col) /= gcd;
+}
----------------
mehdi_amini wrote:
> What guarantees that `gcd` can't be 0 and produce an invalid division here?
> Should we guard this loop?
> 
> (flagged by Coverity)
One of the elements being GCD'd is a "denominator" value that is always non-zero. I will add a comment noting this.


================
Comment at: mlir/lib/Analysis/Presburger/Simplex.cpp:325
+
+    int64_t diff = retConst * elem - constTerm * retElem;
+    if ((diff == 0 && rowUnknown[row] < rowUnknown[*retRow]) ||
----------------
mehdi_amini wrote:
> mehdi_amini wrote:
> > If `retRow` is true, then `retConst` is used uninitialized right? Can you look into this?
> > (flagged by Coverity)
> (Same with  `retElem`)
If `retRow` has a value then lines 319-322 were executed in the iteration that that values was set in, so the values of `retElem` and `retConst` were also set in that iteration already.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80860/new/

https://reviews.llvm.org/D80860



More information about the llvm-commits mailing list