This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author arhadthedev
Recipients arhadthedev, mark.dickinson
Date 2021-11-03.11:13:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635938026.99.0.538390017253.issue45702@roundup.psfhosted.org>
In-reply-to
Content
File configure.ac:4617 states the following:

> # The short float repr introduced in Python 3.1 requires the
> # correctly-rounded string <-> double conversion functions from
> # Python/dtoa.c, which in turn require that the FPU uses 53-bit
> # rounding; this is a problem on x86, where the x87 FPU has a default
> # rounding precision of 64 bits.  For gcc/x86, we can fix this by
> # using inline assembler to get and set the x87 FPU control word.

However, x64 programs use xmm0-7 SIMD registers instead of a FPU stack, so the requirement of hardware 56 bit rounding gets violated. _Py_SET_53BIT_PRECISION_* is unable to do anything here because SSE neither respects the FPU control word, nor provides its own.

Considering that SSE is supported since Pentium III (1999), we can safely enforce its usage for x32 code via compiler flags as well, getting consistent behavior across builds. However, it requires revision of the requirement.

We need to decide what to do with dtoa.c that supposedly relies on the requirement (providing short floats? It looks like _Py_dg_dtoa just stringifies as many digits as specified in ndigits argument. I didn't collect enough courage on this stage to analyze 484 uncommented lines (2370-2854) of bit manipulation over two-letter variables to find and fix the dependency). By the way, the only place that uses _Py_dg_dtoa is Objects/floatobject.c:949 doing it with an argument mode=3.

I can resolve the issue, but I need some educated opinion on this 13-years old stuff (see git blame for configure.ac:4617) to not break things.

Note: I initially added Mark Dickinson into the notifications as a person who created and maintained Python/dtoa.c until 2013.
History
Date User Action Args
2021-11-03 11:13:47arhadthedevsetrecipients: + arhadthedev, mark.dickinson
2021-11-03 11:13:46arhadthedevsetmessageid: <1635938026.99.0.538390017253.issue45702@roundup.psfhosted.org>
2021-11-03 11:13:46arhadthedevlinkissue45702 messages
2021-11-03 11:13:46arhadthedevcreate