Re-enable "[SCEV] Prove implications of different type via truncation"
authorMax Kazantsev <mkazantsev@azul.com>
Wed, 28 Oct 2020 06:28:39 +0000 (13:28 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Wed, 28 Oct 2020 09:02:14 +0000 (16:02 +0700)
commit5ef84688fba28b9f0f69ddc9a5beb75b10696798
treea4e5c25bc31d8c76d16e4787bc9f05b14e2359f2
parent066737fdbc8fe22c48649c388ff2421d596ba2a8
Re-enable "[SCEV] Prove implications of different type via truncation"

When we need to prove implication of expressions of different type width,
the default strategy is to widen everything to wider type and prove in this
type. This does not interact well with AddRecs with negative steps and
unsigned predicates: such AddRec will likely not have a `nuw` flag, and its
`zext` to wider type will not be an AddRec. In contraty, `trunc` of an AddRec
in some cases can easily be proved to be an `AddRec` too.

This patch introduces an alternative way to handling implications of different
type widths. If we can prove that wider type values actually fit in the narrow type,
we truncate them and prove the implication in narrow type.

The return was due to revert of underlying patch that this one depends on.

Unit test temporarily disabled because the required logic in SCEV is switched
off due to compile time reasons.

Differential Revision: https://reviews.llvm.org/D89548
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/srem.ll
llvm/unittests/Analysis/ScalarEvolutionTest.cpp