summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/APIntTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove some unneeded headers and replace some headers with forward class ↵Mehdi Amini2016-04-161-1/+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
* APInt: Add overload of isMaskMatt Arsenault2016-04-121-0/+17
| | | | | | | This mimics the version in MathExtras.h which isn't testing for a specific mask size. llvm-svn: 266101
* Implement constant folding for bitreverseMatt Arsenault2016-03-211-0/+42
| | | | llvm-svn: 263945
* Fix APInt value initialization to give a zero value as any sane integer typeRichard Smith2015-09-041-0/+7
| | | | | | | should, rather than giving a broken value that doesn't even zero/sign-extend properly. llvm-svn: 246836
* Change APInt comparison with uint64_t.Pawel Bylica2015-07-011-0/+127
| | | | | | | | | | | | | | | | | Summary: This patch changes the way APInt is compared with a value of type uint64_t. Before the uint64_t value was truncated to the size of APInt before comparison. Now the comparison takes into account full 64-bit precision. Test Plan: Unit tests added. No regressions. Self-hosted check-all done as well. Reviewers: chandlerc, dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10655 llvm-svn: 241204
* Add missing <array> include.Pawel Bylica2015-06-251-0/+1
| | | | llvm-svn: 240629
* Express APInt::{s,u}{l,g}e(uint64_t) in terms of ↵Pawel Bylica2015-06-251-0/+38
| | | | | | | | | APInt::{s,u}{l,g}t(uint64_t). NFC. This is preparation for http://reviews.llvm.org/D10655: Change APInt comparison with uint64_t. Some unit tests added also. llvm-svn: 240626
* [APInt] Remove special case for i1.Benjamin Kramer2015-06-041-0/+6
| | | | | | Add a unit test. llvm-svn: 239062
* Fix APInt long division algorithmPawel Bylica2015-04-241-182/+66
| | | | | | | | | | | | | | | | 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
* Another test to exercise APInt divide step D6.Yaron Keren2015-04-221-0/+13
| | | | | | This is divrem_big7 since divrem_big6 is used in Pawel upcoming patch. llvm-svn: 235536
* Fix rare case where APInt divide algorithm applied un-needed transformation.Yaron Keren2015-03-261-0/+200
| | | | | | | | | | | | | | | 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/+40
| | | | | | | To complement getSplat. This is more general than the binary decomposition method as it also handles non-pow2 splat sizes. llvm-svn: 233195
* Disable -Wunknown-pragmas in a test so that Clang without -Wself-move will notRichard Trieu2015-01-141-0/+4
| | | | | | complain that the flag doesn't exist. llvm-svn: 225931
* Silence warnings about unknown pragmas for compilers that are not Clang. NFC.Aaron Ballman2015-01-131-1/+4
| | | | llvm-svn: 225788
* Disable a warning for self move since the test is checking for this behavior.Richard Trieu2015-01-131-0/+4
| | | | llvm-svn: 225754
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-4/+4
| | | | | | just letting them be implicitly created. llvm-svn: 216525
* Fix -Wsign-compare warningsDavid Blaikie2014-08-121-3/+3
| | | | llvm-svn: 215483
* APInt: Make self-move-assignment a no-op to fix stage3 clang-clReid Kleckner2014-08-121-0/+17
| | | | | | | | | | | | | | | | | | | | | | It's not clear what the semantics of a self-move should be. The consensus appears to be that a self-move should leave the object in a moved-from state, which is what our existing move assignment operator does. However, the MSVC 2013 STL will perform self-moves in some cases. In particular, when doing a std::stable_sort of an already sorted APSInt vector of an appropriate size, one of the merge steps will self-move half of the elements. We don't notice this when building with MSVC, because MSVC will not synthesize the move assignment operator for APSInt. Presumably MSVC does this because APInt, the base class, has user-declared special members that implicitly delete move special members. Instead, MSVC selects the copy-assign operator, which defends against self-assignment. Clang, on the other hand, selects the move-assign operator, and we get garbage APInts. llvm-svn: 215478
* Clean up whitespaceDuncan P. N. Exon Smith2014-01-311-2/+2
| | | | llvm-svn: 200579
* [APInt] Fix nearestLogBase2 to return correct answers for very large APInt ↵Michael Gottesman2014-01-191-0/+11
| | | | | | | | and APInt with a bitwidth of 1. I also improved the comments, added some more tests, etc. llvm-svn: 199610
* [APInt] Fixed bug where APInt(UINT32_MAX, 0) would blow up when being ↵Michael Gottesman2014-01-191-0/+8
| | | | | | | | | | | | | | constructed. This was due to arithmetic overflow in the getNumBits() computation. Now we cast BitWidth to a uint64_t so that does not occur during the computation. After the computation is complete, the uint64_t is truncated when the function returns. I know that this is not something that is likely to happen, but it *IS* a valid input and we should not blow up. llvm-svn: 199609
* Remove APInt::extractBit since it is already implemented via operator[]. ↵Michael Gottesman2013-12-131-3/+3
| | | | | | Change tests for extractBit to test operator[]. llvm-svn: 197277
* [block-freq] Add the method APInt::nearestLogBase2().Michael Gottesman2013-12-131-4/+40
| | | | llvm-svn: 197272
* [block-freq] Add the APInt method extractBit.Michael Gottesman2013-12-131-0/+26
| | | | llvm-svn: 197271
* [APInt] Implement tcDecrement as a counterpart to tcIncrement. This is for ↵Michael Gottesman2013-05-281-0/+65
| | | | | | | | use in APFloat IEEE-754R 2008 nextUp/nextDown function. rdar://13852078 llvm-svn: 182801
* Move the SplatByte helper to APInt and generalize it a bit.Benjamin Kramer2013-02-201-0/+10
| | | | llvm-svn: 175621
* ADT: Correct APInt::getActiveWords for zero valuesMeador Inge2013-02-071-0/+8
| | | | | | | | | | PR15138 was opened because of a segfault in the Bitcode writer. The actual issue ended up being a bug in APInt where calls to APInt::getActiveWords returns a bogus value when the APInt value is 0. This patch fixes the problem by ensuring that getActiveWords returns 1 for 0 valued APInts. llvm-svn: 174641
* Sort the #include lines for unittest/...Chandler Carruth2012-12-041-2/+2
| | | | llvm-svn: 169250
* fix the quotient returned by sdivrem() for the case when LHS is negative and ↵Nuno Lopes2012-05-221-0/+28
| | | | | | | | RHS is positive based on a patch by Preston Briggs, with some modifications llvm-svn: 157231
* Add a unittest for rotating a really big APInt.Benjamin Kramer2012-02-071-0/+4
| | | | | | Clang miscompiles it under certain circumstances, and it's a good exercise for APInt. llvm-svn: 149986
* Some unittests for APInt rotates; patch by Cameron McInally.Eli Friedman2011-12-221-0/+32
| | | | llvm-svn: 147186
* APInt: update asserts for base-36Dylan Noblesmith2011-12-161-3/+3
| | | | | | | | Hexatridecimal was added in r139695. And fix the unittest that now triggers the assert. llvm-svn: 146754
* Fix APInt::operator*= so that it computes the correct result for large ↵Eli Friedman2011-10-071-0/+9
| | | | | | 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
* Add APInt support for converting to/from hexatridecimal stringsDouglas Gregor2011-09-141-1/+24
| | | | llvm-svn: 139695
* Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor to prevent future ↵Jeffrey Yasskin2011-07-181-0/+4
| | | | | | | | | ambiguity errors like the one corrected by r135261. Migrate all LLVM callers of the old constructor to the new one. llvm-svn: 135431
* unittests: add test for APInt::toString()Dylan Noblesmith2011-06-151-0/+46
| | | | | | Follow up to r133032. llvm-svn: 133107
* Add an argument to APInt's magic udiv calculation to specify the number of ↵Benjamin Kramer2011-03-171-0/+2
| | | | | | | | bits that are known zero in the divided number. This will come in handy soon. llvm-svn: 127828
* The signed version of our "magic number" computation for the integer ↵Cameron Zwarich2011-02-211-0/+18
| | | | | | | | | | | | | approximation of a constant had a minor typo introduced when copying it from the book, which caused it to favor negative approximations over positive approximations in many cases. Positive approximations require fewer operations beyond the multiplication. In the case of division by 3, we still generate code that is a single instruction larger than GCC's code. llvm-svn: 126097
* PR5207: Rename overloaded APInt methods set(), clear(), flip() toJay Foad2010-12-011-1/+1
| | | | | | setAllBits(), setBit(unsigned), etc. llvm-svn: 120564
* Attempt to unbreak the FreeBSD buildbot by XFAILing a unit test that seems to beJakob Stoklund Olesen2010-09-141-0/+5
| | | | | | | | miscompiled by the system gcc-4.2.1 The test remains enabled for the second-stage test. llvm-svn: 113824
* Switch from EXPECT_EQ({true,false, ...) to the more canonicalChandler Carruth2010-07-131-2/+2
| | | | | | | EXPECT_{TRUE,FALSE}(...) macros. This also prevents suprious warnings about bool-to-pointer conversion that occurs withit EXPECT_EQ. llvm-svn: 108248
* Fix death tests in -Asserts builds.Jeffrey Yasskin2010-03-171-0/+2
| | | | llvm-svn: 98701
* Pacify the compiler (signed with unsigned comparison) by makingDuncan Sands2009-10-131-6/+6
| | | | | | these constants unsigned. llvm-svn: 83962
* Add a ceilLogBase2 function to APInt.Dan Gohman2009-10-131-0/+11
| | | | llvm-svn: 83932
* Fix a few more conversion warnings on 4.0Daniel Dunbar2009-09-181-5/+5
| | | | llvm-svn: 82232
* Another try at fixing compile warnings on 4.0Daniel Dunbar2009-09-171-18/+18
| | | | llvm-svn: 82148
* Attempt to fix some 4.0.0 build warnings.Daniel Dunbar2009-09-141-23/+23
| | | | llvm-svn: 81752
* Simplify, now that gtest supports raw_ostream directly.Daniel Dunbar2009-09-061-8/+0
| | | | llvm-svn: 81102
* split raw_os_ostream out to its own header and implementation file. ThisChris Lattner2009-08-241-1/+1
| | | | | | | means that raw_ostream no longer has to #include <iosfwd>. Nothing in llvm should use raw_os_ostream.h, but llvm-gcc and some unit tests do. llvm-svn: 79886
* Unbreak unit tests.Daniel Dunbar2009-08-241-0/+7
| | | | llvm-svn: 79879
OpenPOWER on IntegriCloud