shithub: mc

Download patch

ref: d25b147ccbeff5b7f086b2e43d835543aaa8e6dd
parent: cbdb7d937450b0905b465fec2be2f84a66541cbc
author: S. Gilles <[email protected]>
date: Tue Apr 17 15:38:45 EDT 2018

Boilerplate FP control word code for ASM round.

--- a/lib/math/round-impl+posixy-x64-sse4.s
+++ b/lib/math/round-impl+posixy-x64-sse4.s
@@ -2,7 +2,16 @@
 .globl math$_rn32
 math$rn32:
 math$_rn32:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	subq	$16, %rsp
+	fnstcw	(%rsp)
+	fnstcw	8(%rsp)
+	andl	$0xf3ff, 8(%rsp)
+	fldcw	8(%rsp)
 	cvtss2si	%xmm0, %eax
+	fldcw	(%rsp)
+	leave
 	ret
 
 .globl math$rn64
@@ -9,6 +18,15 @@
 .globl math$_rn64
 math$rn64:
 math$_rn64:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	subq	$16, %rsp
+	fnstcw	(%rsp)
+	fnstcw	8(%rsp)
+	andl	$0xf3ff, 8(%rsp)
+	fldcw	8(%rsp)
 	cvtsd2si	%xmm0, %rax
+	fldcw	(%rsp)
+	leave
 	ret