diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2013-05-05 16:29:20 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2013-05-05 16:29:20 +0000 |
commit | b257a6d283f6f5784cb351856b5dbe8c645a1f6f (patch) | |
tree | 3e134e46c53a5e75a3b6c78878d07a554b396367 /runtime/ia32 | |
parent | bc24cf49659f91245d8f42ca06fbe7d21a5c06cd (diff) |
ia32/i64_dtou: wrong play on rounding mode
arm, powerpc: expand shifts inline in dtos and dtou
arm: branchless code for shl and shr
test: more tests for double -> long long conversions.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2234 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'runtime/ia32')
-rw-r--r-- | runtime/ia32/i64_dtou.S | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/runtime/ia32/i64_dtou.S b/runtime/ia32/i64_dtou.S index cdd2381..4903f84 100644 --- a/runtime/ia32/i64_dtou.S +++ b/runtime/ia32/i64_dtou.S @@ -40,12 +40,6 @@ FUNCTION(__i64_dtou) subl $4, %esp - // Change rounding mode to "round towards zero" - fnstcw 0(%esp) - movw 0(%esp), %ax - movb $12, %ah - movw %ax, 2(%esp) - fldcw 2(%esp) // Compare argument with 2^63 fldl 8(%esp) flds LC1 @@ -54,18 +48,36 @@ FUNCTION(__i64_dtou) sahf jbe 1f // branch if not (ARG < 2^63) // Argument < 2^63: convert as is + // Change rounding mode to "round towards zero" + fnstcw 0(%esp) + movw 0(%esp), %ax + movb $12, %ah + movw %ax, 2(%esp) + fldcw 2(%esp) + // Convert fistpll 8(%esp) movl 8(%esp), %eax movl 12(%esp), %edx - jmp 2f + // Restore rounding mode + fldcw 0(%esp) + addl $4, %esp + ret // Argument > 2^63: offset ARG by -2^63, then convert, then offset RES by 2^63 1: fsubs LC1 + // Change rounding mode to "round towards zero" + fnstcw 0(%esp) + movw 0(%esp), %ax + movb $12, %ah + movw %ax, 2(%esp) + fldcw 2(%esp) + // Convert fistpll 8(%esp) movl 8(%esp), %eax movl 12(%esp), %edx + // Offset result by 2^63 addl $0x80000000, %edx // Restore rounding mode -2: fldcw 0(%esp) + fldcw 0(%esp) addl $4, %esp ret |