summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APInt.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove some unneeded headers and replace some headers with forward class ↵Mehdi Amini2016-04-161-0/+1
| | | | | | | | | | | declarations (NFC) Differential Revision: http://reviews.llvm.org/D19154 Patch by Eugene Kosov <claprix@yandex.ru> From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266524
* Implement constant folding for bitreverseMatt Arsenault2016-03-211-0/+30
| | | | llvm-svn: 263945
* Remove uses of builtin comma operator.Richard Trieu2016-02-181-2/+4
| | | | | | Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261270
* APInt: Slightly simplify countLeadingZerosSlowCase()Matthias Braun2016-02-151-19/+8
| | | | | | | | | We always clear the unused bits in the most signifant word so there is no need to mask them out in countLeadingZerosSlowCase(). Differential Revision: http://reviews.llvm.org/D16621 llvm-svn: 260911
* APInt: Further simplify APInt::EqualSlowCase as suggested by DuncanMatthias Braun2016-02-151-4/+1
| | | | llvm-svn: 260910
* APInt: Simplify EqualSlowCaseMatthias Braun2016-02-101-15/+2
| | | | | | | | | | | | | Previously the code used getActiveBits() to determine the highest set bit of each APInt first. However doing so requires the same amount of memory accesses as simply comparing both numbers right away. Removing all the active bit checks leads to simpler code and is faster in my benchmark. Differential Revision: http://reviews.llvm.org/D16620 llvm-svn: 260447
* Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren2016-01-291-1/+1
| | | | | | | | r259192 post commit comment. clang part in r259232, this is the LLVM part of the patch. llvm-svn: 259240
* Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko2015-06-231-1/+1
| | | | | | Apparently, the style needs to be agreed upon first. llvm-svn: 240390
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-191-1/+1
| | | | | | | | | | | | | The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
* Fix APInt long division algorithmPawel Bylica2015-04-241-19/+9
| | | | | | | | | | | | | | | | Summary: This patch fixes step D4 of Knuth's division algorithm implementation. Negative sign of the step result was not always detected due to incorrect "borrow" handling. Test Plan: Unit test that reveals the bug included. Reviewers: chandlerc, yaron.keren Reviewed By: yaron.keren Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9196 llvm-svn: 235699
* Test commit. Improve comments in APInt. NFC.Pawel Bylica2015-04-061-10/+9
| | | | llvm-svn: 234158
* Fix rare case where APInt divide algorithm applied un-needed transformation.Yaron Keren2015-03-261-34/+19
| | | | | | | | | | | | | | | APInt uses Knuth's D algorithm for long division. In rare cases the implementation applied a transformation that was not needed. Added unit tests for long division. KnuthDiv() procedure is fully covered. There is a case in APInt::divide() that I believe is never used (marked with a comment) as all users of divide() handle trivial cases earlier. Patch by Pawel Bylica! http://reviews.llvm.org/D8448 llvm-svn: 233312
* [APInt] Add an isSplat helper and use it in some places.Benjamin Kramer2015-03-251-0/+8
| | | | | | | To complement getSplat. This is more general than the binary decomposition method as it also handles non-pow2 splat sizes. llvm-svn: 233195
* Remove many superfluous SmallString::str() calls.Yaron Keren2015-03-181-1/+1
| | | | | | | | | | | | | | | Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
* Teach raw_ostream to accept SmallString.Yaron Keren2015-03-101-1/+1
| | | | | | | | | | | | | | Saves adding .str() call to any raw_ostream << SmallString usage and a small step towards making .str() consistent in the ADTs by removing one of the SmallString::str() use cases, discussion at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141013/240026.html I'll update the Phabricator patch http://reviews.llvm.org/D6372 for review of the Twine SmallString support, it's more complex than this one. llvm-svn: 231763
* Drop the hacks used for partial C99 math libraries.Benjamin Kramer2015-03-091-5/+0
| | | | | | All supported platforms have half-way decent C99 support. llvm-svn: 231679
* MathExtras: Bring Count(Trailing|Leading)Ones and CountPopulation in line ↵Benjamin Kramer2015-02-121-5/+5
| | | | | | | | with countTrailingZeros Update all callers. llvm-svn: 228930
* APInt: udivrem should use machine instructions for single-word APIntsDavid Majnemer2014-12-141-0/+12
| | | | | | | | This mirrors the behavior of APInt::udiv and APInt::urem. Some architectures, like X86, have a single instruction which can compute both division and remainder. llvm-svn: 224217
* InstCombine: Don't miscompile (x lshr C1) udiv C2David Majnemer2014-10-131-5/+15
| | | | | | | | | | | | | We have a transform that changes: (x lshr C1) udiv C2 into: x udiv (C2 << C1) However, it is unsafe to do so if C2 << C1 discards any of C2's bits. This fixes PR21255. llvm-svn: 219634
* Modernize old-style static asserts. NFC.Benjamin Kramer2014-10-121-2/+1
| | | | llvm-svn: 219588
* APInt: Unfold return expressions so RVO can work.Benjamin Kramer2014-10-101-10/+28
| | | | | | Saves a couple of expensive deep copies. NFC. llvm-svn: 219487
* typoSanjay Patel2014-09-111-1/+1
| | | | llvm-svn: 217597
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-221-1/+2
| | | | | | definition below all of the header #include lines, lib/Support edition. llvm-svn: 206847
* [C++11] Make use of 'nullptr' in the Support library.Craig Topper2014-04-071-6/+6
| | | | llvm-svn: 205697
* Fix known typosAlp Toker2014-01-241-1/+1
| | | | | | | Sweep the codebase for common typos. Includes some changes to visible function names that were misspelt. llvm-svn: 200018
* Remove APInt::extractBit since it is already implemented via operator[]. ↵Michael Gottesman2013-12-131-8/+0
| | | | | | Change tests for extractBit to test operator[]. llvm-svn: 197277
* [block-freq] Add the APInt method extractBit.Michael Gottesman2013-12-131-0/+8
| | | | llvm-svn: 197271
* APInt: Simplify code. No functionality change.Benjamin Kramer2013-06-011-36/+2
| | | | llvm-svn: 183073
* [APInt] Implement tcDecrement as a counterpart to tcIncrement. This is for ↵Michael Gottesman2013-05-281-0/+14
| | | | | | | | use in APFloat IEEE-754R 2008 nextUp/nextDown function. rdar://13852078 llvm-svn: 182801
* Replace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.Michael J. Spencer2013-05-241-5/+5
| | | | llvm-svn: 182680
* Use pre-inc, pre-dec when possible.Jakub Staszak2013-03-201-4/+4
| | | | | | They are generally faster (at least not slower) than post-inc, post-dec. llvm-svn: 177608
* Move part of APInt implementation from header to cpp file. These methodsJakub Staszak2013-02-201-0/+40
| | | | | | | require call cpp file anyway, so we wouldn't gain anything by keeping them inline. llvm-svn: 175579
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-2/+2
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
* Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. ↵Sylvestre Ledru2012-09-271-4/+4
| | | | | | See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767 llvm-svn: 164768
* Fix a typo 'iff' => 'if'Sylvestre Ledru2012-09-271-4/+4
| | | | llvm-svn: 164767
* PR13326: Fix a subtle edge case in the udiv -> magic multiply generator.Benjamin Kramer2012-07-111-1/+1
| | | | | | This caused 6 of 65k possible 8 bit udivs to be wrong. llvm-svn: 160058
* Fix a crash in APInt::lshr when shiftAmt > BitWidth.Chad Rosier2012-06-081-1/+1
| | | | | | Patch by James Benton <jbenton@vmware.com>. llvm-svn: 158213
* Move APInt::operator[] inline.Benjamin Kramer2012-03-141-6/+0
| | | | llvm-svn: 152692
* Move APInt::operator! inline, it's small and fuses well with surrounding ↵Benjamin Kramer2012-03-141-10/+0
| | | | | | code when inlined. llvm-svn: 152688
* Inline a trivial helper function.Benjamin Kramer2012-03-121-7/+3
| | | | llvm-svn: 152577
* Replace a hand-coded leading one counting loop with the magic from MathExtras.h.Benjamin Kramer2012-03-111-8/+1
| | | | llvm-svn: 152545
* Replace the hashing functions on APInt and APFloat with overloads of theChandler Carruth2012-03-041-87/+6
| | | | | | | | | | | | | | new hash_value infrastructure, and replace their implementations using hash_combine. This removes a complete copy of Jenkin's lookup3 hash function (which is both significantly slower and lower quality than the one implemented in hash_combine) along with a somewhat scary xor-only hash function. Now that APInt and APFloat can be passed directly to hash_combine, simplify the rest of the LLVMContextImpl hashing to use the new infrastructure. llvm-svn: 152004
* Fix undefined behavior.Ahmed Charles2012-02-241-1/+1
| | | | llvm-svn: 151385
* Add r149110 back with a fix for when the vector and the int have the sameRafael Espindola2012-01-271-0/+12
| | | | | | width. llvm-svn: 149151
* Fix APInt::rotl and APInt::rotr so that they work correctly. Found while ↵Eli Friedman2011-12-221-12/+4
| | | | | | writing some code that tried to use them. llvm-svn: 147134
* APInt: update asserts for base-36Dylan Noblesmith2011-12-161-1/+5
| | | | | | | | Hexatridecimal was added in r139695. And fix the unittest that now triggers the assert. llvm-svn: 146754
* Fix unreachable return & simplify some branches.David Blaikie2011-12-011-9/+5
| | | | llvm-svn: 145627
* Correctly byte-swap APInts with bit-widths greater than 64.Richard Smith2011-11-231-17/+26
| | | | llvm-svn: 145111
* Fix APInt::operator*= so that it computes the correct result for large ↵Eli Friedman2011-10-071-1/+2
| | | | | | integers where there is unsigned overflow. Fix APFloat::toString so that it doesn't depend on the incorrect behavior in common cases (and computes the correct result in some rare cases). Fixes PR11086. llvm-svn: 141441
* U is good enoughDouglas Gregor2011-09-201-2/+2
| | | | llvm-svn: 140166
OpenPOWER on IntegriCloud