[ValueTracking] peek through shuffles in ComputeNumSignBits (PR37549)
authorSanjay Patel <spatel@rotateright.com>
Fri, 26 Oct 2018 21:05:14 +0000 (21:05 +0000)
committerSanjay Patel <spatel@rotateright.com>
Fri, 26 Oct 2018 21:05:14 +0000 (21:05 +0000)
commitcc9e401e3cf11bf353bf7b2734f89fcb74f16d95
treed423c18faa74513d583f237d5493ebc7dc189f92
parent7bf85f5c8dd1a6d49581eaf1fdd489eac79e2115
[ValueTracking] peek through shuffles in ComputeNumSignBits (PR37549)

The motivating case is from PR37549:
https://bugs.llvm.org/show_bug.cgi?id=37549

The analysis improvement allows us to form a vector 'select' out of
bitwise logic (the use of ComputeNumSignBits was added at rL345149).

The smaller test shows another InstCombine improvement - we use
ComputeNumSignBits to add 'nsw' to shift-left. But the negative
test shows an example where we must not add 'nsw' - when the shuffle
mask contains undef elements.

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

llvm-svn: 345429
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/logical-select.ll
llvm/test/Transforms/InstCombine/nsw.ll