[Openmcl-devel] bug in optimizer on x86-64 (bignum code)

Eric Marsden eric.marsden at free.fr
Mon Jun 26 14:13:33 PDT 2006


The following code (extracted from cl-bench, originally by Bruno
Haible) illustrates a bug in the compiler on x86-64 (current CVS). The
assertion is not triggered unless the optimization settings are

(declaim (optimize (speed 3) (space 1) (safety 0) (debug 0) (compilation-speed 0)))

(defvar *x1*)
(defvar *x2*)
(defvar *x3*)
(defvar *y*)
(defvar *z*)

(defun pari-benchmark (N repeat)
  (dotimes (count 3)
    (dotimes (_ repeat)
      (let ((u 1) (v 1) (p 1) (q 1))
        (do ((k 1 (1+ k)))
            ((> k N) (setq *y* p *z* q))
          (let ((w (+ u v)))
            (shiftf u v w)
            (setq p (* p w))
            (setq q (lcm q w)))))))
  (integer-length (+ *y* *z*)))

(defun run-pari-100-10 ()
  (assert (eql 3529 (pari-benchmark 100 10))))

Eric Marsden

More information about the Openmcl-devel mailing list