InstCombine: Don't unconditionally preserve 'nuw' when shrinking constants
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 22 Aug 2014 17:11:04 +0000 (17:11 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 22 Aug 2014 17:11:04 +0000 (17:11 +0000)
commit5939f08f5e7aa84fa154136a7977969c176a057e
tree21a31b1848344e2625ba17909603a38fb0b21f4a
parent0e4fc41b0d952f8185af8c4199efa2a3571f2552
InstCombine: Don't unconditionally preserve 'nuw' when shrinking constants

Consider:
  %add = add nuw i32 %a, -16777216
  %and = and i32 %add, 255

Regardless of whether or not we demand the sign bit of %add, we cannot
replace -16777216 with 2130706432 without also removing 'nuw' from the
instruction.

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