]> git.lizzy.rs Git - rust.git/commit
Fix fast path of float parsing on x87
authorAndrea Canciani <ranma42@gmail.com>
Wed, 4 May 2016 14:08:21 +0000 (16:08 +0200)
committerAndrea Canciani <ranma42@gmail.com>
Fri, 13 May 2016 13:18:31 +0000 (15:18 +0200)
commit78124a2b32d61a3ab1cc5798828195970438262b
tree7a4b4a8f796de72bb3afe2c48a77d4d3d9adaef2
parenta581c82bdc2c13a398b091878d7353bc3d097d59
Fix fast path of float parsing on x87

The fast path of the float parser relies on the rounding to happen
exactly and directly to the correct number of bits. On x87, instead,
double rounding would occour as the FPU stack defaults to 80 bits of
precision.

This can be fixed by setting the precision of the FPU stack before
performing the int to float conversion. This can be achieved by
changing the value of the x87 control word. This is a somewhat common
operation that is in fact performed whenever a float needs to be
truncated to an integer, but it is undesirable to add its overhead for
code that does not rely on x87 for computations (i.e. on non-x86
architectures, or x86 architectures which perform FPU computations on
using SSE).

Fixes `num::dec2flt::fast_path_correct` (on x87).
src/libcore/lib.rs
src/libcore/num/dec2flt/algorithm.rs