Duplicated code with use of special variables (x86-64 linux)

Bug #1784136 reported by Paul F. Dietz on 2018-07-28
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

I noticed a lot of duplicated code when a function with multiple uses of a special variable is compiled. Can these be collapsed somehow?

(declaim (optimize speed space safety (debug 0)))

(defun f2 () (list *x* *x* *x*))

(compile 'f2)

(disassemble 'f2) ==>

; disassembly for F2
; Size: 192 bytes. Origin: #x1004C3929F
; 29F: 8B042594565020 MOV EAX, [#x20505694] ; no-arg-parsing entry point
                                                              ; tls_index: *X*
; 2A6: 4A8B0428 MOV RAX, [RAX+R13]
; 2AA: 83F861 CMP EAX, 97
; 2AD: 480F44042598565020 CMOVEQ RAX, [#x20505698] ; *X*
; 2B6: 83F851 CMP EAX, 81
; 2B9: 0F848C000000 JEQ L2
; 2BF: 8B342594565020 MOV ESI, [#x20505694] ; tls_index: *X*
; 2C6: 4A8B342E MOV RSI, [RSI+R13]
; 2CA: 83FE61 CMP ESI, 97
; 2CD: 480F44342598565020 CMOVEQ RSI, [#x20505698] ; *X*
; 2D6: 83FE51 CMP ESI, 81
; 2D9: 7473 JEQ L3
; 2DB: 8B1C2594565020 MOV EBX, [#x20505694] ; tls_index: *X*
; 2E2: 4A8B1C2B MOV RBX, [RBX+R13]
; 2E6: 83FB61 CMP EBX, 97
; 2E9: 480F441C2598565020 CMOVEQ RBX, [#x20505698] ; *X*
; 2F2: 83FB51 CMP EBX, 81
; 2F5: 745A JEQ L4
; 2F7: 49896D40 MOV [R13+64], RBP ; thread.pseudo-atomic-bits
; 2FB: 4D8B5D20 MOV R11, [R13+32] ; thread.alloc-region
; 2FF: 498D7B30 LEA RDI, [R11+48]
; 303: 493B7D28 CMP RDI, [R13+40]
; 307: 774B JNBE L5
; 309: 49897D20 MOV [R13+32], RDI ; thread.alloc-region
; 30D: L0: 498D7B07 LEA RDI, [R11+7]
; 311: 488BCF MOV RCX, RDI
; 314: 488941F9 MOV [RCX-7], RAX
; 318: 4883C110 ADD RCX, 16
; 31C: 488949F1 MOV [RCX-15], RCX
; 320: 488971F9 MOV [RCX-7], RSI
; 324: 4883C110 ADD RCX, 16
; 328: 488949F1 MOV [RCX-15], RCX
; 32C: 488959F9 MOV [RCX-7], RBX
; 330: 48C7410117001020 MOV QWORD PTR [RCX+1], #x20100017 ; NIL
; 338: 49316D40 XOR [R13+64], RBP ; thread.pseudo-atomic-bits
; 33C: 7402 JEQ L1
; 33E: CC09 BREAK 9 ; pending interrupt trap
; 340: L1: 488BD7 MOV RDX, RDI
; 343: 488BE5 MOV RSP, RBP
; 346: F8 CLC
; 347: 5D POP RBP
; 348: C3 RET
; 349: CC0F BREAK 15 ; Invalid argument count trap
; 34B: L2: CC17 BREAK 23 ; UNBOUND-SYMBOL-ERROR
; 34D: 13 BYTE #X13 ; '*X*
; 34E: L3: CC17 BREAK 23 ; UNBOUND-SYMBOL-ERROR
; 350: 13 BYTE #X13 ; '*X*
; 351: L4: CC17 BREAK 23 ; UNBOUND-SYMBOL-ERROR
; 353: 13 BYTE #X13 ; '*X*
; 354: L5: 6A30 PUSH 48
; 356: FF14252800B021 CALL QWORD PTR [#x21B00028] ; ALLOC-TRAMP-R11
; 35D: EBAE JMP L0

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

Other bug subscribers