[IndVars] Use symbolic max block exit count to handle the last iter
authorMax Kazantsev <mkazantsev@azul.com>
Fri, 9 Dec 2022 10:05:33 +0000 (17:05 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Fri, 9 Dec 2022 10:06:29 +0000 (17:06 +0700)
commit262f2fed65b83ba9b64227b983d5ed95883fd71e
treeb50e729e6a1e709b7b40df5be066ddc3ebf034ce
parent412a139d1f8d06d0d0fe4fa1c8fc66f51154c3f1
[IndVars] Use symbolic max block exit count to handle the last iter

Old logic: when loop symbolic max exit count matched *exact* block exit count,
assume that all subsequent blocks will do 1 iteration less.

New logic: when loop symbolic max exit count matched *symbolic max* block exit count,
assume that all subsequent blocks will do 1 iteration less.

The new logic is still legal and is more permissive in situations when exact
block exit count is not known.

Differential Revision: https://reviews.llvm.org/D139692
Reviewed By: nikic
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/test/Transforms/IndVarSimplify/turn-to-invariant.ll