OSDN Git Service

InstCombine: Annotate sub with nsw when we prove it's safe
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 19 Aug 2014 23:36:30 +0000 (23:36 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 19 Aug 2014 23:36:30 +0000 (23:36 +0000)
commite0134d95cc14a040592e5d07ff14c4619e50a071
tree3b29510559a2a56c64d064ecc264a5f137b2b1a5
parent06de8a10d2e596c5aae94d60466532773105cc6b
InstCombine: Annotate sub with nsw when we prove it's safe

We can prove that a 'sub' can be a 'sub nsw' under certain conditions:
- The sign bits of the operands is the same.
- Both operands have more than 1 sign bit.

The subtraction cannot be a signed overflow in either case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216037 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombine.h
lib/Transforms/InstCombine/InstCombineAddSub.cpp
test/Transforms/InstCombine/memcmp-1.ll
test/Transforms/InstCombine/strcmp-1.ll
test/Transforms/InstCombine/strncmp-1.ll
test/Transforms/InstCombine/sub-xor.ll
test/Transforms/InstCombine/sub.ll