[Openmcl-devel] Bug in integer arithmetic (AMD64)

Ron Garret ron at flownet.com
Wed Jul 20 10:31:26 PDT 2011


The analogous bug exists in ccl32 as well:

Welcome to Clozure Common Lisp Version 1.7-dev-r14832M-trunk  (DarwinX8632)!
? (let ((a 1)) (* 33554433 -1 a))
33554432

My bet is it's a bug in this assembly code:

(define-x8664-vinsn multiply-fixnums (((dest :imm))
                                      ((x :imm)
                                       (y :imm))
                                      ((unboxed :s64)))
  ((:pred =
          (:apply %hard-regspec-value x)
          (:apply %hard-regspec-value dest))
   (movq (:%q y) (:%q unboxed))
   (sarq (:$ub x8664::fixnumshift) (:%q unboxed))
   (imulq (:%q unboxed) (:%q dest)))
  ((:and (:not (:pred =
                      (:apply %hard-regspec-value x)
                      (:apply %hard-regspec-value dest)))
         (:pred =
                (:apply %hard-regspec-value y)
                (:apply %hard-regspec-value dest)))
   (movq (:%q x) (:%q unboxed))
   (sarq (:$ub x8664::fixnumshift) (:%q unboxed))
   (imulq (:%q unboxed) (:%q dest)))
  ((:and (:not (:pred =
                      (:apply %hard-regspec-value x)
                      (:apply %hard-regspec-value dest)))
         (:not (:pred =
                      (:apply %hard-regspec-value y)
                      (:apply %hard-regspec-value dest))))
   (movq (:%q y) (:%q dest))
   (movq (:%q x) (:%q unboxed))
   (sarq (:$ub x8664::fixnumshift) (:%q unboxed))
   (imulq (:%q unboxed) (:%q dest))))

But this is beyond my ability to decipher.

rg

On Jul 20, 2011, at 3:52 AM, Eric Marsden wrote:

> Surprising!
> 
> ,----
> | ? (lisp-implementation-version)
> | "Version 1.7-dev-r14890M  (LinuxX8664)"
> | ? (let ((a 1)) (* 144115188075855873 a -1))
> | 144115188075855872
> `----
> 
> -- 
> Eric Marsden
> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list