From e99b2b29bf65f7a2a678e9d7199085bf4aabd81a Mon Sep 17 00:00:00 2001
From: Raymond Toy <toy.raymond@gmail.com>
Date: Sat, 26 Oct 2013 17:01:54 -0700
Subject: [PATCH] Document why %unary-ftruncate multiplies the result by x when
 result = 0.

---
 src/compiler/float-tran.lisp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/compiler/float-tran.lisp b/src/compiler/float-tran.lisp
index a107e7937..187d17b13 100644
--- a/src/compiler/float-tran.lisp
+++ b/src/compiler/float-tran.lisp
@@ -210,10 +210,9 @@
 ;; if x is known to be of the right type.  Also, if the result is
 ;; known to fit in the same range as a (signed-byte 32), convert this
 ;; to %unary-truncate, which might be a single instruction, and float
-;; the result.  However, for sparc, we have a vop to do this so call
-;; that, and for Sparc V9, we can actually handle a 64-bit integer
-;; range.
-
+;; the result.  However, for sparc and x86, we have a vop to do this
+;; so call that, and for Sparc V9, we can actually handle a 64-bit
+;; integer range.
 (macrolet ((frob (ftype func)
 	     `(deftransform %unary-ftruncate ((x) (,ftype))
 	       (let* ((x-type (continuation-type x))
@@ -226,6 +225,9 @@
 			  (< hi limit-hi))
 		     #-(or sparc (and x86 sse2))
 		     '(let ((result (coerce (%unary-truncate x) ',ftype)))
+		       ;; Multiply by x when result is 0 so that we
+		       ;; get the correct signed zero to match what
+		       ;; ftruncate in float.lisp would return.
 		       (if (zerop result)
 			   (* result x)
 			   result))
-- 
GitLab