#20: Modular arith bug? ---------------------+------------------------------------------------------ Reporter: rtoy | Owner: somebody Type: defect | Status: new Priority: major | Milestone: Component: Core | Version: 19e Resolution: | Keywords: ---------------------+------------------------------------------------------ Old description:
{{{ (defun mat3neg (tt v) (ldb (byte 32 0) (ash v (- tt))))
(defun mat3neg-a (tt v) (logand #xffffffff (ash v (- tt))))
(defun zot (z2) (declare (type (unsigned-byte 32) z2) (optimize speed (safety 0))) (mat3neg -28 z2))
(defun zot-a (z2) (declare (type (unsigned-byte 32) z2) (optimize speed (safety 0))) (mat3neg-a -28 z2)) }}}
Compile {{{zot}}} and there are lots of compiler notes, from {{{mat3neg}}}. But compile {{{zot-a}}} and there's just one for boxing up the result.
However, {{{zot}}} and {{{zot-a}}} are functionally identical, so {{{zot}}} and {{{zot-a}}} should produce the same code. But {{{zot}}} has to do a full call to {{{ash}}} and {{{two-arg-and}}}.
The {{{ldb}}} must be confusing the compiler somehow.
New description:
{{{ (declaim (inline mat3neg mat3neg-a)) (defun mat3neg (tt v) (ldb (byte 32 0) (ash v (- tt))))
(defun mat3neg-a (tt v) (logand #xffffffff (ash v (- tt))))
(defun zot (z2) (declare (type (unsigned-byte 32) z2) (optimize speed (safety 0))) (mat3neg -28 z2))
(defun zot-a (z2) (declare (type (unsigned-byte 32) z2) (optimize speed (safety 0))) (mat3neg-a -28 z2)) }}}
Compile {{{zot}}} and there are lots of compiler notes, from {{{mat3neg}}}. But compile {{{zot-a}}} and there's just one for boxing up the result.
However, {{{zot}}} and {{{zot-a}}} are functionally identical, so {{{zot}}} and {{{zot-a}}} should produce the same code. But {{{zot}}} has to do a full call to {{{ash}}} and {{{two-arg-and}}}.
The {{{ldb}}} must be confusing the compiler somehow.