[PATCH] D87832: [IndVars] Remove monotonic checks with unknown exit count

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 04:11:59 PDT 2020


mkazantsev added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:9252
+  // Try to prove the following set of facts:
+  // - The predicate is monotonic.
+  // - If the check does not fail on the 1st iteration:
----------------
fhahn wrote:
> IIUC  there a reason we cannot use `isMonotonicPredicate` here is that it is not using the information from MaxIter (which is the max exit count in the case of this patch)? Would it be possible move the logic to use the max exit count of a loop into `isMonotonicPredicate`?
The main reason is that `isMonotonicPredicate ` checks no-wrap flag, and we are interested in unsigned range for IV with negative step. Formally, it overflows on every iteration. So `isMonotonicPredicate` cannot deal with it.

Theoretically we could expand `isMonotonicPredicate`, making it smarter and able to handle this. But it is used in 3 different transforms, and such change would have unpredictable impact. So I'd rather do it separately.



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

https://reviews.llvm.org/D87832



More information about the llvm-commits mailing list