BACKGROUND
When using 64bit Steel Bank Common Lisp on Windows for a trivial identity function:
(defun a (x)
(declare (fixnum x))
(declare (optimize (speed 3) (safety 0)))
(the fixnum x))
I find the disassembly is given as:
* (disassemble 'a)
; disassembly for A
; Size: 13 bytes
; 02D7DFA6: 84042500000F20 TEST AL, [#x200F0000] ; safepoint
; no-arg-parsing entry point
; AD: 488BE5 MOV RSP, RBP
; B0: F8 CLC
; B1: 5D POP RBP
; B2: C3 RET
I understand that the lines:
mov rsp, rbp
pop rbp
ret
perform standard return from function operations, but I don't understand why there are the lines:
TEST AL, [#x200F0000] // My understanding is that this sets flags based on bitwise and of AL and contents of memory 0x200F0000
and
CLC // My understanding is that this clears the carry flag.
QUESTIONS
- Why does SBCL generate a test instruction, but never use the flags?
- Why does SBCL clear the carry flag before returning from a function?
TEST AL
in either SBCL or Allegro Lisp. – Hord