From b257a6d283f6f5784cb351856b5dbe8c645a1f6f Mon Sep 17 00:00:00 2001 From: xleroy Date: Sun, 5 May 2013 16:29:20 +0000 Subject: 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 --- runtime/ia32/i64_dtou.S | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'runtime/ia32/i64_dtou.S') diff --git a/runtime/ia32/i64_dtou.S b/runtime/ia32/i64_dtou.S index cdd23814..4903f847 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 -- cgit