Step #2 to improve trip count analysis for loops like this:
authorChris Lattner <sabre@nondot.org>
Sun, 9 Jan 2011 22:26:35 +0000 (22:26 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 9 Jan 2011 22:26:35 +0000 (22:26 +0000)
commit992efb03785f2a368fbb63b09373be1d6a96ce5a
tree14906ff0c13ed69b70d5155ea2a375da023e5205
parent42e9c963921776cb498c33b6c6c03f29971316f3
Step #2 to improve trip count analysis for loops like this:

void f(int* begin, int* end) { std::fill(begin, end, 0); }

which turns into a != exit expression where one pointer is
strided and (thanks to step #1) known to not overflow, and
the other is loop invariant.

The observation here is that, though the IV is strided by
4 in this case, that the IV *has* to become equal to the
end value.  It cannot "miss" the end value by stepping over
it, because if it did, the strided IV expression would
eventually wrap around.

Handle this by turning A != B into "A-B != 0" where the A-B
part is known to be NUW.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123131 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolution.h
lib/Analysis/ScalarEvolution.cpp