Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

(jmpq (@ .SPBUILTIN-TIMES))

So, this is going to be really slow inside a loop. Would the compiler be able to optimize it into a single multiply instruction if it could prove that the input had to contain integers?



  CL-USER> (defun f (x)
             (declare (fixnum x)
                      (optimize speed (safety 0) (debug 0)))
               (the fixnum (* x x)))

  CL-USER> (disassemble #'f)
  ; disassembly for F
  ; Size: 19 bytes
  ; 0337CE2F:       488BCA           MOV RCX, RDX               ; no-arg-parsing entry point
  ;       32:       48D1F9           SAR RCX, 1
  ;       35:       480FAFCA         IMUL RCX, RDX
  ;       39:       488BD1           MOV RDX, RCX
  ;       3C:       488BE5           MOV RSP, RBP
  ;       3F:       F8               CLC
  ;       40:       5D               POP RBP
  ;       41:       C3               RET
  NIL




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: