InstCombine: Correctly propagate NSW/NUW for x-(-A) -> x+A
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 31 Jul 2014 04:49:29 +0000 (04:49 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 31 Jul 2014 04:49:29 +0000 (04:49 +0000)
commita4a812feddfe542c2cfe13641d2cf012058e1c2d
treef5a3bd4e9422a874fa0adc136d0d0f47b4177ee2
parentec7ee070369dd4074f7ad3ac4555ebb9421b8c1a
InstCombine: Correctly propagate NSW/NUW for x-(-A) -> x+A

We can only propagate the nsw bits if both subtraction instructions are
marked with the appropriate bit.

N.B.  We only propagate the nsw bit in InstCombine because the nuw case
is already handled in InstSimplify.

This fixes PR20189.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214385 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAddSub.cpp
test/Transforms/InstCombine/sub.ll