Teach ScalarEvolution to sharpen range information.
authorSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 13 Nov 2014 00:00:58 +0000 (00:00 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 13 Nov 2014 00:00:58 +0000 (00:00 +0000)
commitde87c9165ae2afb696fcd10bdd18e97756624e09
treef308101273832d6f91d5a3460c7ed45836f24ce9
parent72c32c6c824004f4327796b70de1694a2f09c9e2
Teach ScalarEvolution to sharpen range information.

If x is known to have the range [a, b), in a loop predicated by (icmp
ne x, a) its range can be sharpened to [a + 1, b).  Get
ScalarEvolution and hence IndVars to exploit this fact.

This change triggers an optimization to widen-loop-comp.ll, so it had
to be edited to get it to pass.

This change was originally landed in r219834 but had a bug and broke
ASan. It was reverted in r219878, and is now being re-landed after
fixing the original bug.

phabricator: http://reviews.llvm.org/D5639
reviewed by: atrick

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221839 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolution.cpp
test/Transforms/IndVarSimplify/sharpen-range.ll [new file with mode: 0644]
test/Transforms/IndVarSimplify/widen-loop-comp.ll