#18: Modular arith bug 1 --------------------+------------------------------------------------------- Reporter: rtoy | Owner: somebody Type: defect | Status: new Priority: minor | Milestone: Component: Core | Version: 19d Keywords: | --------------------+------------------------------------------------------- Not really a bug, but a deficiency.
{{{ (defun ref (a n) (declare (type (simple-array single-float (*)) a) (type (integer 0 15) n) (optimize (speed 3) (safety 0))) (aref a (logand #xf (+ n 15)))) }}}
Relevant disassembly on sparc:
{{{ 68: SRA %A1, 2, %NL0 ; %A1 = N ; No-arg-parsing entry point ; [:NON-LOCAL- ENTRY] 6C: ADD 15, %NL0 70: AND 15, %NL0 74: SLL %NL0, 2, %NL1 78: ADD %NL1, 1, %NL0 7C: LDF [%A0+%NL0], %F0 ; %A0 = A }}}
So {{{N}}} is converted from a fixnum to an integer, the appropriate operations are done, and then converted back to a fixnum. All of this could have been done without the conversion like so:
{{{ 40: ADD 60, %A1 ; %A1 = N ; No-arg-parsing entry point ; [:NON-LOCAL- ENTRY] 44: AND 60, %A1 48: ADD %A1, 1, %NL0 4C: LDF [%A0+%NL0], %F0 ; %A0 = A }}}
#18: Modular arith bug 1 ---------------------+------------------------------------------------------ Reporter: rtoy | Owner: somebody Type: defect | Status: closed Priority: minor | Milestone: Component: Core | Version: 19d Resolution: fixed | Keywords: ---------------------+------------------------------------------------------ Changes (by rtoy):
* resolution: => fixed * status: new => closed
Comment:
This should be fixed in the 2008-09 snapshot. The cost for various VOPs were tweaked slightly to allow the fixnum VOPs a chance to run.