I looked at libgcc's implementation (which is based on the paper,
Software for Doubled-Precision Floating-Point Computations", by Seppo Linnainmaa,
ACM TOMS vol 7 no 3, September 1981, pages 272-283.) and made it generic to
arbitrary IEEE floats.
Details
- Reviewers
scanon echristo kbarton iteratee hfinkel - Commits
- rG18e7ae672ef7: [APFloatTest] Use std::make_tuple to make GCC 4.8 happy
rG44bde896a5f8: [APFloat] Implement PPCDoubleDouble add and subtract.
rL289474: [APFloatTest] Use std::make_tuple to make GCC 4.8 happy
rL289472: [APFloat] Implement PPCDoubleDouble add and subtract.
Diff Detail
- Build Status
Buildable 2075 Build 2075: arc lint + arc unit
Event Timeline
Can you please comment on how similar/different this algorithm is from the one in compiler-rt/lib/builtins/ppc/gcc_qadd.c (and other nearby files)?
I didn't look at compiler-rt/lib/builtins/ppc/gcc_qadd.c. These algorithms take time to reason about, so currently the only thing I know is that they are different :P. I chose libgcc's version, because it has a paper to refer to.
Okay, can you explain your comment about overflow/underflow. Can't you do it the same way that the libgcc implementations do?
Added more comments to the implementation, and propagate all status of the internal computations to the returned status.
You are right. libgcc just let the underlying double arithmetic modify the fenv exception flags, so we should do the same thing.
llvm/lib/Support/APFloat.cpp | ||
---|---|---|
4078 | The magnitude of Floats[0] should be greater than that of Floats[1]. |
llvm/lib/Support/APFloat.cpp | ||
---|---|---|
4078 |
It's possible, e.g. (+1.0, -1e-100), which models mathematical 1-1e-100. And yes, the magnitude of Floats[0] is greater than Floats[1]. APFloat has special category flags for zero, so Floats[1] is completely ignored when Floats[0].getCategory() is Zero. |
I believe that now it's mostly behaving in the same way as libgcc does, except for one bug that libgcc has (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78759), but I fixed it here.
Couple of small inline nits. Willing to go with it on the implementation details.
Adding Steve in case he wishes to comment.
-eric
llvm/lib/Support/APFloat.cpp | ||
---|---|---|
4071 | Still an empty string :) | |
4163 | Since you're adding a Print you might want to add a dump as well. (And while I realize it's against how the class currently works Print->print please). |
llvm/lib/Support/APFloat.cpp | ||
---|---|---|
3949 | It looks here like q = (a - z), but it would be useful to put that in the comment explicitly. Also, is there a reason for computing (a - (q + z)) as -((q + z) - a)? |
It looks here like q = (a - z), but it would be useful to put that in the comment explicitly. Also, is there a reason for computing (a - (q + z)) as -((q + z) - a)?