1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

58 Commits

Author SHA1 Message Date
Richard Smith
e8f2654b47 Fix APInt value initialization to give a zero value as any sane integer type
should, rather than giving a broken value that doesn't even zero/sign-extend
properly.

llvm-svn: 246836
2015-09-04 04:08:36 +00:00
Pawel Bylica
87cf433a3d Change APInt comparison with uint64_t.
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
2015-07-01 22:56:43 +00:00
Pawel Bylica
8b05f5ba5d Add missing <array> include.
llvm-svn: 240629
2015-06-25 10:47:08 +00:00
Pawel Bylica
91ca53a942 Express APInt::{s,u}{l,g}e(uint64_t) in terms of 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
2015-06-25 10:23:52 +00:00
Benjamin Kramer
cc65db81cb [APInt] Remove special case for i1.
Add a unit test.

llvm-svn: 239062
2015-06-04 18:19:13 +00:00
Pawel Bylica
f959036c26 Fix APInt long division algorithm
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
2015-04-24 07:38:39 +00:00
Yaron Keren
6e87be5234 Another test to exercise APInt divide step D6.
This is divrem_big7 since divrem_big6 is used in Pawel upcoming patch.

llvm-svn: 235536
2015-04-22 18:49:59 +00:00
Yaron Keren
7c2f11d4be Fix rare case where APInt divide algorithm applied un-needed transformation.
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
2015-03-26 19:45:19 +00:00
Benjamin Kramer
3deba1d2df [APInt] Add an isSplat helper and use it in some places.
To complement getSplat. This is more general than the binary
decomposition method as it also handles non-pow2 splat sizes.

llvm-svn: 233195
2015-03-25 16:49:59 +00:00
Richard Trieu
d6743940e6 Disable -Wunknown-pragmas in a test so that Clang without -Wself-move will not
complain that the flag doesn't exist.

llvm-svn: 225931
2015-01-14 01:50:12 +00:00
Aaron Ballman
ed32ba7ebd Silence warnings about unknown pragmas for compilers that are not Clang. NFC.
llvm-svn: 225788
2015-01-13 14:30:07 +00:00
Richard Trieu
499c1ba6e9 Disable a warning for self move since the test is checking for this behavior.
llvm-svn: 225754
2015-01-13 02:10:33 +00:00
Craig Topper
43cee2f5fc Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or just letting them be implicitly created.
llvm-svn: 216525
2014-08-27 05:25:25 +00:00
David Blaikie
e490f547d3 Fix -Wsign-compare warnings
llvm-svn: 215483
2014-08-12 23:23:05 +00:00
Reid Kleckner
3f1f5c1808 APInt: Make self-move-assignment a no-op to fix stage3 clang-cl
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
2014-08-12 22:01:39 +00:00
Duncan P. N. Exon Smith
e9a572242c Clean up whitespace
llvm-svn: 200579
2014-01-31 21:45:51 +00:00
Michael Gottesman
181ec670ce [APInt] Fix nearestLogBase2 to return correct answers for very large APInt and APInt with a bitwidth of 1.
I also improved the comments, added some more tests, etc.

llvm-svn: 199610
2014-01-19 20:33:48 +00:00
Michael Gottesman
7a8ef6d280 [APInt] Fixed bug where APInt(UINT32_MAX, 0) would blow up when being 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
2014-01-19 20:33:38 +00:00
Michael Gottesman
4c26c21fc1 Remove APInt::extractBit since it is already implemented via operator[]. Change tests for extractBit to test operator[].
llvm-svn: 197277
2013-12-13 22:00:19 +00:00
Michael Gottesman
10caac931c [block-freq] Add the method APInt::nearestLogBase2().
llvm-svn: 197272
2013-12-13 20:47:37 +00:00
Michael Gottesman
7ed19350c0 [block-freq] Add the APInt method extractBit.
llvm-svn: 197271
2013-12-13 20:47:34 +00:00
Michael Gottesman
2a51955f08 [APInt] Implement tcDecrement as a counterpart to tcIncrement. This is for use in APFloat IEEE-754R 2008 nextUp/nextDown function.
rdar://13852078

llvm-svn: 182801
2013-05-28 19:50:20 +00:00
Benjamin Kramer
a2f37d8d3b Move the SplatByte helper to APInt and generalize it a bit.
llvm-svn: 175621
2013-02-20 13:00:06 +00:00
Meador Inge
58a7392486 ADT: Correct APInt::getActiveWords for zero values
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
2013-02-07 18:36:50 +00:00
Chandler Carruth
f413c260cc Sort the #include lines for unittest/...
llvm-svn: 169250
2012-12-04 10:23:08 +00:00
Nuno Lopes
328f9efec2 fix the quotient returned by sdivrem() for the case when LHS is negative and RHS is positive
based on a patch by Preston Briggs, with some modifications

llvm-svn: 157231
2012-05-22 01:09:48 +00:00
Benjamin Kramer
6d9863be3a Add a unittest for rotating a really big APInt.
Clang miscompiles it under certain circumstances, and it's a good exercise for APInt.

llvm-svn: 149986
2012-02-07 16:27:39 +00:00
Eli Friedman
41be35819d Some unittests for APInt rotates; patch by Cameron McInally.
llvm-svn: 147186
2011-12-22 22:11:19 +00:00
Dylan Noblesmith
91b9af8f44 APInt: update asserts for base-36
Hexatridecimal was added in r139695.

And fix the unittest that now triggers the assert.

llvm-svn: 146754
2011-12-16 20:36:31 +00:00
Eli Friedman
433785c651 Fix APInt::operator*= so that it computes the correct result for large 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
2011-10-07 23:40:49 +00:00
Douglas Gregor
8c0777c5f3 Add APInt support for converting to/from hexatridecimal strings
llvm-svn: 139695
2011-09-14 15:54:46 +00:00
Jeffrey Yasskin
2e0f2a0985 Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor to prevent future ambiguity
errors like the one corrected by r135261.  Migrate all LLVM callers of the old
constructor to the new one.

llvm-svn: 135431
2011-07-18 21:45:40 +00:00
Dylan Noblesmith
b75ad906fa unittests: add test for APInt::toString()
Follow up to r133032.

llvm-svn: 133107
2011-06-15 23:36:34 +00:00
Benjamin Kramer
a85996c235 Add an argument to APInt's magic udiv calculation to specify the number of bits that are known zero in the divided number.
This will come in handy soon.

llvm-svn: 127828
2011-03-17 20:39:06 +00:00
Cameron Zwarich
b7e676db6c The signed version of our "magic number" computation for the integer 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
2011-02-21 00:22:02 +00:00
Jay Foad
789e8ac4f7 PR5207: Rename overloaded APInt methods set(), clear(), flip() to
setAllBits(), setBit(unsigned), etc.

llvm-svn: 120564
2010-12-01 08:53:58 +00:00
Jakob Stoklund Olesen
0a9b86f575 Attempt to unbreak the FreeBSD buildbot by XFAILing a unit test that seems to be
miscompiled by the system gcc-4.2.1

The test remains enabled for the second-stage test.

llvm-svn: 113824
2010-09-14 00:51:58 +00:00
Chandler Carruth
e3d4a2cbbc Switch from EXPECT_EQ({true,false, ...) to the more canonical
EXPECT_{TRUE,FALSE}(...) macros. This also prevents suprious warnings about
bool-to-pointer conversion that occurs withit EXPECT_EQ.

llvm-svn: 108248
2010-07-13 17:28:05 +00:00
Jeffrey Yasskin
4443f00d2b Fix death tests in -Asserts builds.
llvm-svn: 98701
2010-03-17 01:18:45 +00:00
Duncan Sands
19c1644f1f Pacify the compiler (signed with unsigned comparison) by making
these constants unsigned.

llvm-svn: 83962
2009-10-13 09:23:11 +00:00
Dan Gohman
f9067da535 Add a ceilLogBase2 function to APInt.
llvm-svn: 83932
2009-10-13 01:49:02 +00:00
Daniel Dunbar
d4df08bb72 Fix a few more conversion warnings on 4.0
llvm-svn: 82232
2009-09-18 17:48:05 +00:00
Daniel Dunbar
b415837d62 Another try at fixing compile warnings on 4.0
llvm-svn: 82148
2009-09-17 17:46:53 +00:00
Daniel Dunbar
23724b98d0 Attempt to fix some 4.0.0 build warnings.
llvm-svn: 81752
2009-09-14 02:38:53 +00:00
Daniel Dunbar
7ef30987f7 Simplify, now that gtest supports raw_ostream directly.
llvm-svn: 81102
2009-09-06 02:31:26 +00:00
Chris Lattner
98f201632e split raw_os_ostream out to its own header and implementation file. This
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
2009-08-24 04:02:06 +00:00
Daniel Dunbar
56712ba250 Unbreak unit tests.
llvm-svn: 79879
2009-08-24 02:02:58 +00:00
Bill Wendling
e5dbd6b0f9 Correct for recent assert change.
llvm-svn: 79601
2009-08-21 06:35:41 +00:00
Erick Tryzelaar
ff8b504eb3 Fix bug with APInt::getBitsNeeded with for base 10 numbers 0-9.
llvm-svn: 79593
2009-08-21 03:15:28 +00:00
Erick Tryzelaar
11660bb729 Allow '+' to appear in APInt strings, and add more unit tests.
llvm-svn: 79592
2009-08-21 03:15:14 +00:00