diff options
author | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2020-03-29 11:20:01 +0200 |
---|---|---|
committer | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2020-03-30 17:26:17 +0200 |
commit | f1abe04e503f1c54c5a50f7b3f3906beca15a760 (patch) | |
tree | c348b8cd5f6683d03eda0bfb8b528e9a12a76b18 /runtime/arm | |
parent | f2de2518509f198c5ce958ec06c18e78e896f814 (diff) | |
download | compcert-kvx-f1abe04e503f1c54c5a50f7b3f3906beca15a760.tar.gz compcert-kvx-f1abe04e503f1c54c5a50f7b3f3906beca15a760.zip |
Double rounding error in int64->float32 conversions on PowerPC and ARM
The "stof" and "utof" runtime functions contain a round-to-odd step
that avoids double rounding. However, this step was incorrectly coded
on PowerPC (stof and utof), PowerPC64 (utof), and ARM (stof), making
round-to-odd ineffective and causing double rounding.
Closes: #343
Diffstat (limited to 'runtime/arm')
-rw-r--r-- | runtime/arm/i64_stof.S | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/runtime/arm/i64_stof.S b/runtime/arm/i64_stof.S index bcfa471c..11e00a2a 100644 --- a/runtime/arm/i64_stof.S +++ b/runtime/arm/i64_stof.S @@ -39,12 +39,11 @@ @@@ Conversion from signed 64-bit integer to single float FUNCTION(__compcert_i64_stof) - @ Check whether -2^53 <= X < 2^53 - ASR r2, Reg0HI, #21 - ASR r3, Reg0HI, #31 @ (r2,r3) = X >> 53 + @ Check whether -2^53 <= X < 2^53 + ASR r2, Reg0HI, #21 @ r2 = high 32 bits of X >> 53 + @ -2^53 <= X < 2^53 iff r2 is -1 or 0, that is, iff r2 + 1 is 0 or 1 adds r2, r2, #1 - adc r3, r3, #0 @ (r2,r3) = X >> 53 + 1 - cmp r3, #2 + cmp r2, #2 blo 1f @ X is large enough that double rounding can occur. @ Avoid it by nudging X away from the points where double rounding |