diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-11-13 22:17:26 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-11-13 22:23:50 +0100 |
commit | 9a85643cd357e412cff69067bb5c4840e228c2ab (patch) | |
tree | 142e9c5d475070e2ba2f6bec9b5cfabd3218dbc7 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | a2f2c2f3a46351bc5478acd290258d318af2cd88 (diff) | |
download | llvm-9a85643cd357e412cff69067bb5c4840e228c2ab.zip llvm-9a85643cd357e412cff69067bb5c4840e228c2ab.tar.gz llvm-9a85643cd357e412cff69067bb5c4840e228c2ab.tar.bz2 |
[KnownBits] Combine abs() implementations
ValueTracking was using a more powerful abs() implementation. Roll
it into KnownBits::abs(). Also add an exhaustive test for abs(),
in both the poisoning and non-poisoning variants.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index e6d3727..a3c139d 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1511,28 +1511,12 @@ static void computeKnownBitsFromOperator(const Operator *I, if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) { switch (II->getIntrinsicID()) { default: break; - case Intrinsic::abs: + case Intrinsic::abs: { computeKnownBits(I->getOperand(0), Known2, Depth + 1, Q); - - // If the source's MSB is zero then we know the rest of the bits. - if (Known2.isNonNegative()) { - Known.Zero |= Known2.Zero; - Known.One |= Known2.One; - break; - } - - // Absolute value preserves trailing zero count. - Known.Zero.setLowBits(Known2.Zero.countTrailingOnes()); - - // If this call is undefined for INT_MIN, the result is positive. We - // also know it can't be INT_MIN if there is a set bit that isn't the - // sign bit. - Known2.One.clearSignBit(); - if (match(II->getArgOperand(1), m_One()) || Known2.One.getBoolValue()) - Known.Zero.setSignBit(); - // FIXME: Handle known negative input? - // FIXME: Calculate the negated Known bits and combine them? + bool IntMinIsPoison = match(II->getArgOperand(1), m_One()); + Known = Known2.abs(IntMinIsPoison); break; + } case Intrinsic::bitreverse: computeKnownBits(I->getOperand(0), DemandedElts, Known2, Depth + 1, Q); Known.Zero |= Known2.Zero.reverseBits(); |