[ValueTracking] Teach computeKnownBits that the result of an absolute value pattern that uses nsw flag is always positive.

If the nsw flag is used in the absolute value then it is undefined for INT_MIN. For all other value it will produce a positive number. So we can assume the result is positive.

This breaks some InstCombine abs/nabs combining tests because we simplify the second compare from known bits rather than as the whole pattern. Looks like we can probably fix it by adding a neg+abs/nabs combine to just swap the select operands. Need to check alive to make sure there are no corner cases.

Differential Revision: https://reviews.llvm.org/D47041

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333226 91177308-0d34-0410-b5e6-96231b3b80d8
3 files changed