OSDN Git Service

[ValueTracking] Don't do an unchecked shift in ComputeNumSignBits
authorSanjoy Das <sanjoy@playingwithpointers.com>
Sat, 25 Feb 2017 20:30:45 +0000 (20:30 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Sat, 25 Feb 2017 20:30:45 +0000 (20:30 +0000)
commit9b2526d03d18b5dedbc4dd3470b3b0fb37fc4c2e
tree42edeba7105fb03475847b9eb27ba073cb0f24e7
parent95d021ba685c54ba516442811f5926a4f6d2cf9a
[ValueTracking] Don't do an unchecked shift in ComputeNumSignBits

Summary:
Previously we used to return a bogus result, 0, for IR like `ashr %val,
-1`.

I've also added an assert checking that `ComputeNumSignBits` at least
returns 1.  That assert found an already checked in test case where we
were returning a bad result for `ashr %val, -1`.

Fixes PR32045.

Reviewers: spatel, majnemer

Reviewed By: spatel, majnemer

Subscribers: efriedma, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296273 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ValueTracking.cpp
test/Transforms/IndVarSimplify/pr32045.ll [new file with mode: 0644]
unittests/Analysis/ValueTrackingTest.cpp