#
df6cf5ab |
| 24-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
1. Fix last bug in KnuthDiv. All divide tests pass up to 1024 bits now. 2. Clean up comments, style, coding standards, etc. 3. Simplify a constructor.
Extended testing revealed some additional bugs
1. Fix last bug in KnuthDiv. All divide tests pass up to 1024 bits now. 2. Clean up comments, style, coding standards, etc. 3. Simplify a constructor.
Extended testing revealed some additional bugs in shifting. I'll fix these tomorrow.
llvm-svn: 34559
show more ...
|
#
a5e0d200 |
| 24-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
1. Make internal functions take const arguments where they should, just to be safe. 2. Make internal functions that return a carry/borrow return bool instead of uint64_t because the carry/borro
1. Make internal functions take const arguments where they should, just to be safe. 2. Make internal functions that return a carry/borrow return bool instead of uint64_t because the carry/borrow can only be in range [0,1]. 3. Assert that the pointers to KnuthDiv are all different so that the result and operands can't overlap. 4. Add debug output to KnuthDiv function. 5. Fix a problem with KnuthDiv by separating the b's complement operation from the subtraction borrow operation. This fixes a wide range of division problems, but alas, not all of them.
llvm-svn: 34554
show more ...
|
#
cb292e4a |
| 23-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
1. Fix a carry out problem in add if destination and x point to the same memory (as done in fromString). 2. Implement Knuth divide more closely to what is recommended in his book. 3. Fix computati
1. Fix a carry out problem in add if destination and x point to the same memory (as done in fromString). 2. Implement Knuth divide more closely to what is recommended in his book. 3. Fix computation of the remainder for Knuth Divide (bad shifting). 4. Remove some cruft from the file
llvm-svn: 34518
show more ...
|
#
867b4064 |
| 22-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
When converting from 64 to 32-bits, use the actual number of words to extract the value, not the number of words implied by the active bits. This fixes numerous, but not all divide bugs.
llvm-svn: 3
When converting from 64 to 32-bits, use the actual number of words to extract the value, not the number of words implied by the active bits. This fixes numerous, but not all divide bugs.
llvm-svn: 34484
show more ...
|
#
e4ce71d0 |
| 22-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Fix countLeadingZeros in the case that the bitwidth evenly divides the word size. This fixes all reads of uninitialized data (buffer over read) and makes APInt.cpp memory clean, per valgrind. The onl
Fix countLeadingZeros in the case that the bitwidth evenly divides the word size. This fixes all reads of uninitialized data (buffer over read) and makes APInt.cpp memory clean, per valgrind. The only remaining problem is division in a few cases.
llvm-svn: 34483
show more ...
|
#
58a6a43c |
| 21-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Reorganize some code to make it clearer, avoid a few uninitialized memory reads, and reduce the number of temporary APInt instances we construct.
llvm-svn: 34467
|
#
db2abec8 |
| 21-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Fix the carry in addition.
llvm-svn: 34465
|
#
1ba83356 |
| 21-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
1. Add a dump() method for faster debugging. 2. Change 0 initialization of union to larger component so all is zeroed. 3. Fix the borrow logic in subtraction so it works for > 128 bits. 4. Rewrite fr
1. Add a dump() method for faster debugging. 2. Change 0 initialization of union to larger component so all is zeroed. 3. Fix the borrow logic in subtraction so it works for > 128 bits. 4. Rewrite fromString to use a simpler but correct algorithm and also to not set the bit width contrary to the user's request. 5. Optimize toString a bit by making it only do one Knuth divide per iteration instead of two.
With these changes, all arithmetic passes (verified by pari/GP) up to 1024 bits except for certain division cases.
llvm-svn: 34463
show more ...
|
#
74cf82e5 |
| 21-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Fix countLeadingZeros to actually return the correct number. Fix toString to correctly return "0" for zero valued APInts over 128 bits.
llvm-svn: 34459
|
#
7a6a8d51 |
| 20-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Make long addition and subtraction work. Speed things up by using internal functions more.
llvm-svn: 34458
|
#
4bb430c4 |
| 20-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Clean up variable names in operator*. Attempt #3 for getting a portable INFINITY value.
llvm-svn: 34454
|
#
a83af6e1 |
| 20-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Use INFINITY macro from math.h instead of constructing hex floating point constants (avoids warnings).
llvm-svn: 34452
|
#
fb77b2ba |
| 20-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
First version that can process arith.cpp test case up to 1024 bits: 1. Ensure pVal is set to 0 in each constructor. 2. Fix roundToDouble to make correct calculations and not read beyond the end of
First version that can process arith.cpp test case up to 1024 bits: 1. Ensure pVal is set to 0 in each constructor. 2. Fix roundToDouble to make correct calculations and not read beyond the end of allocated memory. 3. Implement Knuth's "classical algorithm" for division from scratch and eliminate buffer overflows and uninitialized mememory reads. Document it properly too. 4. Implement a wrapper function for KnuthDiv which handles the 64-bit to 32-bit conversion and back. It also implement short division for the n == 1 case that Knuth's algorithm can't handle. 5. Simplify the logic of udiv and urem a little, make them exit early, and have them use the "divide" wrapper function to perform the division or remainder operation. 6. Move the toString function to the end of the file, closer to where the division functions are located.
Note: division is still broken for some > 64 bit values, but at least it doesn't crash any more. llvm-svn: 34449
show more ...
|
#
861c1cb6 |
| 18-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
1. Fix some indentation and variable names in the get{Min,Max}Value methods. 2. Implement toString for power-of-2 radix without using divide and always printing full words. This allows hex/binary
1. Fix some indentation and variable names in the get{Min,Max}Value methods. 2. Implement toString for power-of-2 radix without using divide and always printing full words. This allows hex/binary to look at the bit respresentation of the APInt as well as avoid bugs in divide.
llvm-svn: 34396
show more ...
|
#
be4ddf68 |
| 18-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
1. Use APINT_WORD_SIZE instead of sizeof(uint64_t) 2. Teach slt about signedness. 3. Teach roundToDouble to properly sign extend.
llvm-svn: 34391
|
#
a856b6e9 |
| 18-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
1. Remove dead code (lshift function). 2. Consolidate memory allocation into just two inline functions. 3. Convert "unsigned" to uint32_t to gaurantee its size. 4. Eliminate magic constants and repla
1. Remove dead code (lshift function). 2. Consolidate memory allocation into just two inline functions. 3. Convert "unsigned" to uint32_t to gaurantee its size. 4. Eliminate magic constants and replace with symbolic equivalent. 5. Improve code documentation slightly. 6. Simplify the logical operator code because bitwidths must be the same. 7. Fix indentation per coding standards. 8. Use exit-early style to reduce indentation in several functions.
llvm-svn: 34389
show more ...
|
#
ee0a685e |
| 18-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Make add_1 exit early if carry is 0. Fix line breaks and 80 cols violation. Simplify operator^= since bitwidths must be the same.
llvm-svn: 34388
|
#
fbd48a56 |
| 18-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Implement signed output for toString. Fix bugs in countLeadingZeros and countTrailingZeros.
llvm-svn: 34386
|
#
26c6616e |
| 17-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Fix some bugs in division logic.
llvm-svn: 34384
|
#
100502d2 |
| 17-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Move static functions closer to their usage.
llvm-svn: 34363
|
#
3986776f |
| 17-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Clean up the divide and remainder logic a bit (exit early). Use more meaningful variable names. Add comments to document the flow.
llvm-svn: 34362
|
#
a32372d1 |
| 17-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Fix bugs introduced by constructor parameter order change.
llvm-svn: 34357
|
#
1d072120 |
| 16-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Review changes: 1. Function style changes. 2. 80-col violations. 3. Better names for things. 4. Arrange constructors so they all take bit width first. 5. Add named signed and unsigned comparison func
Review changes: 1. Function style changes. 2. 80-col violations. 3. Better names for things. 4. Arrange constructors so they all take bit width first. 5. Add named signed and unsigned comparison functions and remove the corresponding operators. 6. Remove operator&& and operator|| but provide a getBoolValue function which converts to bool as comparison against 0. This allows the normal && and || operators to be used as if (X.getBoolValue() && Y.getBoolValue())
Note: this still doesn't function 100% yet. I'm working on the bugs now. llvm-svn: 34353
show more ...
|
#
cfa2ac05 |
| 15-Feb-2007 |
Zhou Sheng <zhousheng00@gmail.com> |
Fix some buges: 1. Make getMinValue() returns the right value. 2. Fix the ByteSwap() crash problem. 3. Make Postfix increment work correctly. 4. Fix some bugs in LogBase2, Hi/LoBits and UDiv.
llvm-s
Fix some buges: 1. Make getMinValue() returns the right value. 2. Fix the ByteSwap() crash problem. 3. Make Postfix increment work correctly. 4. Fix some bugs in LogBase2, Hi/LoBits and UDiv.
llvm-svn: 34304
show more ...
|
#
0c5db231 |
| 14-Feb-2007 |
Reid Spencer <rspencer@reidspencer.com> |
Use brute-force algorithm for to_string. It doesn't have to be efficient at this point, it just needs to work so we can test things reliably.
llvm-svn: 34262
|