[IndVars] Remove monotonic checks with unknown exit count
authorMax Kazantsev <mkazantsev@azul.com>
Tue, 27 Oct 2020 04:35:16 +0000 (11:35 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Tue, 27 Oct 2020 04:35:16 +0000 (11:35 +0700)
commitc6ca26c0bfedb8f80d6f8cb9adde25b1d6aac1c5
tree4b101cb0385b546ad7d9d2b0b7672154d535fd06
parentd38788b357ad29083eb3b03027db908559aae2a6
[IndVars] Remove monotonic checks with unknown exit count

Even if the exact exit count is unknown, we can still prove that this
exit will not be taken. If we can prove that the predicate is monotonic,
fulfilled on first & last iteration, and no overflow happened in between,
then the check can be removed.

Differential Revision: https://reviews.llvm.org/D87832
Reviewed By: apilipenko
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/test/Transforms/IndVarSimplify/monotonic_checks.ll
llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll