close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Opened 16 years ago

Closed 16 years ago

#18 closed defect (fixed)

Modular arith bug 1

Reported by: Raymond Toy Owned by: somebody
Priority: minor Milestone:
Component: Core Version: 19d
Keywords: Cc:

Description

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

Change History (1)

comment:1 Changed 16 years ago by Raymond Toy

Resolution: fixed
Status: newclosed

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.

Note: See TracTickets for help on using tickets.