Teach ScalarEvolution to exploit min and max expressions when proving
authorSanjoy Das <sanjoy@playingwithpointers.com>
Mon, 15 Dec 2014 22:50:15 +0000 (22:50 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Mon, 15 Dec 2014 22:50:15 +0000 (22:50 +0000)
commit574e01c32e14fc13db509b47fd01b8890cc0cdeb
treeb88f74d3fdcd0e20a9c67bd70ac90c1406c3e530
parent2f7e202f2779bd4ed665abbf8c9537fb43329536
Teach ScalarEvolution to exploit min and max expressions when proving
isKnownPredicate.

The motivation for this change is to optimize away checks in loops
like this:

    limit = min(t, len)
    for (i = 0 to limit)
      if (i >= len || i < 0) throw_array_of_of_bounds();
      a[i] = ...

Differential Revision: http://reviews.llvm.org/D6635

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224285 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolution.cpp
test/Transforms/IndVarSimplify/backedge-on-min-max.ll [new file with mode: 0644]