[LLVMdev] [RFC] Add a simple soft-float class

Owen Anderson resistor at mac.com
Wed Jun 18 13:29:48 PDT 2014


On Jun 18, 2014, at 1:20 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:

> I'm certainly not suggesting this would be better in general than IEEE 754.
> 
> But I think it's suitable for the sorts of places we currently use
> hard-floats.  I guess you (and Philip) are saying there are dragons here?

Numerical analysis is hard.  Every numerics expert I have ever worked with considers trying to re-invent floating point a cardinal sin of numerical analysis.  Just don’t do it.  You will miss important considerations, and you will pay the price for it later.  Plus, anyone in the future who wants to modify your code has to learn a new set of non-standard floating point numerics, and without a well-defined specification it’s not always clear what the correct semantics in a particular case are.

> Although "making APFloat not suck" might be ideal, we don't have the code
> written for that.

I don’t think we should let expedience get in the way of Doing The Right Thing.  IMO, there are two real issues with APFloat today:

1) The interface is really clunky.  We can fix this by fixing/extending the interface, or by adding a convenience wrapper.

2) It *may* be too slow for this use case.  Assuming this is actually true, there’s a lot of room for improvement in APFloat’s performance by special-casing common paths (default rounding mode, normal formats).  We could even conceivably detect if we’re compiled for a platform that has sane hard float support and fall back to that transparently.

None of these seem particularly difficult to me, and saves us from a future world of pain.  I know Michael Gottesman has some WIP code for cleaning up APFloat.  Perhaps he could share it with you?

—Owen



More information about the llvm-dev mailing list