diff options
author | Craig Topper <craig.topper@intel.com> | 2017-06-14 17:04:59 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2017-06-14 17:04:59 +0000 |
commit | f93b7b1c1f0e535b59171e4145cd587e498370f6 (patch) | |
tree | 125193efd6cedcc409ee08a718d3b13f7903acd7 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 02b0e9d97a8d0a519dcb386e7162f3bcbaef3f48 (diff) | |
download | bcm5719-llvm-f93b7b1c1f0e535b59171e4145cd587e498370f6.tar.gz bcm5719-llvm-f93b7b1c1f0e535b59171e4145cd587e498370f6.zip |
[ValueTracking] Correct early out in computeKnownBitsFromOperator to work with non power of 2 bit widths
There's an early out that's trying to detect when we don't know any bits that make up the legal range of a shift. The code subtracts one from BitWidth which creates a mask in the lower bits for power of 2 bit widths. This is then ANDed with the known bits to see if any of those bits are known. If the bit width isn't a power of 2 this creates a non-sensical mask.
This patch corrects this by rounding up to a power of 2 before doing the subtract and mask.
Differential Revision: https://reviews.llvm.org/D34165
llvm-svn: 305400
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 7cb8c8d8aae..b065f427b06 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -852,7 +852,8 @@ static void computeKnownBitsFromShiftOperator( Optional<bool> ShifterOperandIsNonZero; // Early exit if we can't constrain any well-defined shift amount. - if (!(ShiftAmtKZ & (BitWidth - 1)) && !(ShiftAmtKO & (BitWidth - 1))) { + if (!(ShiftAmtKZ & (PowerOf2Ceil(BitWidth) - 1)) && + !(ShiftAmtKO & (PowerOf2Ceil(BitWidth) - 1))) { ShifterOperandIsNonZero = isKnownNonZero(I->getOperand(1), Depth + 1, Q); if (!*ShifterOperandIsNonZero) |