Duplicate assembly when filling small arrays

Bug #2033051 reported by Andrew Kravchuk
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

Hello! Consider the following example (opcodes and byte numbers edited out for clarity):

(disassemble #'(lambda () (declare (optimize (speed 3) (safety 0) (debug 0)))
  (make-array 6 :element-type 'fixnum :initial-element -1)))
; disassembly for (LAMBDA ())
; Size: 124 bytes. Origin: #x5398F226 ; (LAMBDA ())
; MOV [R13+40], R13 ; thread.pseudo-atomic-bits
; MOV RCX, [R13+112] ; thread.mixed-tlab
; LEA RAX, [RCX+64]
; CMP RAX, [R13+120]
; JA L2
; MOV [R13+112], RAX ; thread.mixed-tlab
; L0: MOV BYTE PTR [RCX], -55
; MOV BYTE PTR [RCX+8], 12
; OR CL, 15
; XOR [R13+40], R13 ; thread.pseudo-atomic-bits
; JEQ L1
; INT3 9 ; pending interrupt trap
; L1: MOV RDX, -2
; MOV [RCX+1], RDX
; MOV RDX, -2
; MOV [RCX+9], RDX
; MOV RDX, -2
; MOV [RCX+17], RDX
; MOV RDX, -2
; MOV [RCX+25], RDX
; MOV RDX, -2
; MOV [RCX+33], RDX
; MOV RDX, -2
; MOV [RCX+41], RDX
; MOV RDX, RCX
; LEAVE
; CLC
; RET
; L2: PUSH 64
; CALL [#x50000578] ; #x52A004F0: ALLOC-TRAMP
; POP RCX
; JMP L0
NIL

Have a closer look at code starting at L1 label. I appreciate compiler's effort on unrolling the loop to fill that small array with -1s, but wouldn't it make sense to not to put it into RDX every time?..

My SBCL version is 2.3.7 on Linux.

description: updated
description: updated
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.