Skip to content

Instantly share code, notes, and snippets.

@shirok
Created January 15, 2011 04:03
Show Gist options
  • Save shirok/780685 to your computer and use it in GitHub Desktop.
Save shirok/780685 to your computer and use it in GitHub Desktop.
cl-user> (defun foo (a j)
(declare (optimize (safety 0) (speed 3))
(type (array (unsigned-byte 8)) a))
(let ((ptr (excl::ll :+ a #.(sys::mdparam 'comp::md-lvector-data0-norm)))
(off (excl::ll :fixnum-to-mi j)))
(declare (fixnum ptr off))
(excl::ll :aset-byte ptr off
(excl::ll :- (excl::ll :aref-ubyte ptr j) (excl::ll :fixnum-to-mi 1)))))
foo
cl-user> (compile 'foo)
foo
nil
nil
cl-user> (disassemble 'foo)
;; disassembly of #<Function foo>
;; formals: a j
;; code start: #x1000ca26e8:
0: 48 83 c7 f0 add rdi,$-16
4: 4c 8b ee movq r13,rsi
7: 49 c1 fd 03 sar r13,$3
11: 48 0f b6 34 37 movzbq rsi,[rdi+rsi+0]
16: 48 83 ee 01 sub rsi,$1
20: 42 88 34 2f movb [rdi+r13+0],sil
24: 48 8b fe movq rdi,rsi
27: f8 clc
28: 4c 8b 74 24 10 movq r14,[rsp+16]
33: c3 ret
; No value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment