[SCEV] Unify getUnsignedRange and getSignedRange
authorSanjoy Das <sanjoy@playingwithpointers.com>
Mon, 9 Mar 2015 21:43:43 +0000 (21:43 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Mon, 9 Mar 2015 21:43:43 +0000 (21:43 +0000)
commitcd5029d00108df094b1ed225fb81f4eeece580a9
tree170a01c0a66bd06e494efd693e9de7cb7baee04b
parentafeb9bf44eb3b188c28ebd535e29e5a9b6b32e9a
[SCEV] Unify getUnsignedRange and getSignedRange

Summary:
This removes some duplicated code, and also helps optimization: e.g. in
the test case added, `%idx ULT 128` in `@x` is not currently optimized
to `true` by `-indvars` but will be, after this change.

The only functional change in ths commit is that for add recurrences,
ScalarEvolution::getRange will be more aggressive -- computing the
unsigned (resp. signed) range for a SCEVAddRecExpr will now look at the
NSW (resp. NUW) bits and check for signed (resp. unsigned) overflow.
This can be a strict improvement in some cases (such as the attached
test case), and should be no worse in other cases.

Reviewers: atrick, nlewycky

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231709 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolution.h
lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/range-signedness.ll [new file with mode: 0644]