History log of /llvm-project/llvm/lib/Support/APInt.cpp (Results 126 – 150 of 434)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# a6c142ab 08-May-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Remove 'else' after 'return' in tcMultiply methods. NFC

llvm-svn: 302406


# f15bec55 08-May-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Take advantage of new operator*=(uint64_t) to remove a temporary APInt.

llvm-svn: 302403


# a51941f3 08-May-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Add support for multiplying by a uint64_t.

This makes multiply similar to add, sub, xor, and, and or.

llvm-svn: 302402


# 93c68e11 04-May-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Reduce number of allocations involved in multiplying. Reduce worst case multiply size

Currently multiply is implemented in operator*=. Operator* makes a copy and uses operator*= to modify th

[APInt] Reduce number of allocations involved in multiplying. Reduce worst case multiply size

Currently multiply is implemented in operator*=. Operator* makes a copy and uses operator*= to modify the copy.

Operator*= itself allocates a temporary buffer to hold the multiply result as it computes it. Then copies it to the buffer in *this.

Operator*= attempts to bound the size of the result based on the number of active bits in its inputs. It also has a couple special cases to handle 0 inputs without any memory allocations or multiply operations. The best case is that it calculates a single word regardless of input bit width. The worst case is that it calculates the a 2x input width result and drop the upper bits.

Since operator* uses operator*= it incurs two allocations, one for a copy of *this and one for the temporary allocation. Neither of these allocations are kept after the method operation is done.

The main usage in the backend appears to be ConstantRange::multiply which uses operator* rather than operator*=.

This patch moves the multiply operation to operator* and implements operator*= using it. This avoids the copy in operator*. operator* now allocates a result buffer sized the same width as its inputs no matter what. This buffer will be used as the buffer for the returned APInt. Finally, we reuse tcMultiply to implement the multiply operation. This function is capable of not calculating additional upper words that will be discarded.

This change does lose the special optimizations for the inputs using less words than their size implies. But it also removed the getActiveBits calls from all multiplies. If we think those optimizations are important we could look at providing additional bounds to tcMultiply to limit the computations.

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

llvm-svn: 302171

show more ...


# b339c6dc 03-May-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Give the value union a name so we can remove assumptions on VAL being the larger member

Currently several places assume the VAL member is always at least the same size as pVal. In particular

[APInt] Give the value union a name so we can remove assumptions on VAL being the larger member

Currently several places assume the VAL member is always at least the same size as pVal. In particular for a memcpy in the move assignment operator. While this is a true assumption, it isn't good practice to assume this.

This patch gives the union a name so we can write the memcpy in terms of the union itself. This also adds a similar memcpy to the move constructor where we previously just copied using VAL directly.

This patch is mostly just a mechanical addition of the U in front of VAL and pVAL everywhere. But several constructors had to be modified since we can't directly initializer a field of named union from the initializer list.

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

llvm-svn: 302040

show more ...


# 9881bd9c 02-May-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Move APInt::getSplat out of line.

I think this method is probably too complex to be inlined.

llvm-svn: 301901


# 1e91919a 02-May-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Move the setBit and clearBit methods inline.

This makes setBit/clearBit more consistent with setBits which is already inlined.

llvm-svn: 301900


# 24e71017 28-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Use inplace shift methods where possible. NFCI

llvm-svn: 301612


Revision tags: llvmorg-4.0.1-rc1
# 1dec2811 24-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Simplify the zext and sext methods

This replaces a hand written copy loop with a call to memcpy for both zext and sext.

For sext, it replaces multiple if/else blocks propagating sign inform

[APInt] Simplify the zext and sext methods

This replaces a hand written copy loop with a call to memcpy for both zext and sext.

For sext, it replaces multiple if/else blocks propagating sign information forward. Now we just do a copy, a sign extension on the last copied word, a memset, and clearUnusedBits.

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

llvm-svn: 301201

show more ...


# 8b37326a 24-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Add ashrInPlace method and rewrite ashr to make a copy and then call ashrInPlace.

This patch adds an in place version of ashr to match lshr and shl which were recently added.

I've tried to

[APInt] Add ashrInPlace method and rewrite ashr to make a copy and then call ashrInPlace.

This patch adds an in place version of ashr to match lshr and shl which were recently added.

I've tried to make this similar to the lshr code with additions to handle the sign extension. I've also tried to do this with less if checks than the current ashr code by sign extending the original result to a word boundary before doing any of the shifting. This removes a lot of the complexity of determining where to fill in sign bits after the shifting.

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

llvm-svn: 301198

show more ...


# c6b05684 24-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Fix repeated word in comments. NFC

llvm-svn: 301192


# fc03d2d2 24-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Make behavior of ashr by BitWidth consistent between single and multi word.

Previously single word would always return 0 regardless of the original sign. Multi word would return all 0s or al

[APInt] Make behavior of ashr by BitWidth consistent between single and multi word.

Previously single word would always return 0 regardless of the original sign. Multi word would return all 0s or all 1s based on the original sign. Now single word takes into account the sign as well.

llvm-svn: 301159

show more ...


# 652ca996 23-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] In sext single word case, use SignExtend64 and let the APInt constructor mask off any excess bits.

The current code is trying to be clever with shifts to avoid needing to clear unused bits.

[APInt] In sext single word case, use SignExtend64 and let the APInt constructor mask off any excess bits.

The current code is trying to be clever with shifts to avoid needing to clear unused bits. But it looks like the compiler is unable to optimize out the unused bit handling in the APInt constructor. Given this its better to just use SignExtend64 and have more readable code.

llvm-svn: 301133

show more ...


# 4abfb3d7 23-Apr-2017 Renato Golin <renato.golin@linaro.org>

Revert "[APInt] Fix a few places that use APInt::getRawData to operate within the normal API."

This reverts commit r301105, 4, 3 and 1, as a follow up of the previous
revert, which broke even more b

Revert "[APInt] Fix a few places that use APInt::getRawData to operate within the normal API."

This reverts commit r301105, 4, 3 and 1, as a follow up of the previous
revert, which broke even more bots.

For reference:
Revert "[APInt] Use operator<<= where possible. NFC"
Revert "[APInt] Use operator<<= instead of shl where possible. NFC"
Revert "[APInt] Use ashInPlace where possible."

PR32754.

llvm-svn: 301111

show more ...


# cc4a9120 23-Apr-2017 Renato Golin <renato.golin@linaro.org>

Revert "[APInt] Add ashrInPlace method and implement ashr using it. Also fix a bug in the shift by BitWidth handling."

This reverts commit r301094, as it broke all ARM self-hosting bots.

PR32754.

Revert "[APInt] Add ashrInPlace method and implement ashr using it. Also fix a bug in the shift by BitWidth handling."

This reverts commit r301094, as it broke all ARM self-hosting bots.

PR32754.

llvm-svn: 301110

show more ...


# 5f68af08 23-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Use operator<<= instead of shl where possible. NFC

llvm-svn: 301103


# 26af2a99 22-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Add ashrInPlace method and implement ashr using it. Also fix a bug in the shift by BitWidth handling.

For single word, shift by BitWidth was always returning 0, but for multiword it was base

[APInt] Add ashrInPlace method and implement ashr using it. Also fix a bug in the shift by BitWidth handling.

For single word, shift by BitWidth was always returning 0, but for multiword it was based on original sign. Now single word matches multi word.

llvm-svn: 301094

show more ...


# 3a29e3b8 22-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Remove unnecessary min with BitWidth from countTrailingOnesSlowCase.

The unused upper bits are guaranteed to be 0 so we don't need to worry about accidentally counting them.

llvm-svn: 301091


# 5e113742 22-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Add WORD_MAX constant and use it instead of UINT64_MAX. NFC

llvm-svn: 301069


# 1dc8fc8b 21-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Add compare/compareSigned methods that return -1, 0, 1. Reimplement slt/ult and friends using them

Currently sle and ule have to call slt/ult and eq to get the proper answer. This results in

[APInt] Add compare/compareSigned methods that return -1, 0, 1. Reimplement slt/ult and friends using them

Currently sle and ule have to call slt/ult and eq to get the proper answer. This results in extra code for both calls and additional scans of multiword APInts.

This patch replaces slt/ult with a compareSigned/compare that can return -1, 0, or 1 so we can cover all the comparison functions with a single call.

While I was there I removed the activeBits calls and other checks at the start of the slow part of ult. Both of the activeBits calls potentially scan through each of the APInts separately. I can't imagine that's any better than just scanning them in parallel and doing the compares. Now we just share the code with tcCompare.

These changes seem to be good for about a 7-8k reduction on the size of the opt binary on my local x86-64 build.

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

llvm-svn: 300995

show more ...


# a8129a11 20-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Add isSubsetOf method that can check if one APInt is a subset of another without creating temporary APInts

This question comes up in many places in SimplifyDemandedBits. This makes it easy t

[APInt] Add isSubsetOf method that can check if one APInt is a subset of another without creating temporary APInts

This question comes up in many places in SimplifyDemandedBits. This makes it easy to ask without allocating additional temporary APInts.

The BitVector class provides a similar functionality through its (IMHO badly named) test(const BitVector&) method. Though its output polarity is reversed.

I've provided one example use case in this patch. I plan to do more as a follow up.

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

llvm-svn: 300851

show more ...


# baa392e4 20-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Implement APInt::intersects without creating a temporary APInt in the multiword case

Summary: This is a simple question we should be able to answer without creating a temporary to hold the A

[APInt] Implement APInt::intersects without creating a temporary APInt in the multiword case

Summary: This is a simple question we should be able to answer without creating a temporary to hold the AND result. We can also get an early out as soon as we find a word that intersects.

Reviewers: RKSimon, hans, spatel, davide

Reviewed By: hans, davide

Subscribers: llvm-commits

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

llvm-svn: 300812

show more ...


# b3624e4f 19-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Implement operator==(uint64_t) similar to ugt/ult(uint64_t) to remove one of the out of line EqualsSlowCase methods.

llvm-svn: 300799


# c67fe57e 19-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Move the 'return *this' from the slow cases of assignment operators inline. We should let the compiler see that the fast/slow cases both return *this.

I don't think we chain assignments toge

[APInt] Move the 'return *this' from the slow cases of assignment operators inline. We should let the compiler see that the fast/slow cases both return *this.

I don't think we chain assignments together very often so this shouldn't matter much.

llvm-svn: 300715

show more ...


# ae8bd67d 18-Apr-2017 Craig Topper <craig.topper@gmail.com>

[APInt] Inline the single word case of lshrInPlace similar to what we do for <<=.

llvm-svn: 300577


12345678910>>...18