Optimization?
Heh! I'll answer my own question...(defun ceiling-pwr2 (n)
(declare (fixnum n))
(declare (optimize (speed 3) (safety 0) (space 3) (float 0)))
(let ((nn (sys:integer-to-int32 n)))
(declare (sys:int32 nn))
(labels ((iter (n nsh)
(declare (sys:int32 n))
(declare (fixnum nsh))
(sys:int32-logior n (sys:int32>> n nsh))))
(declare (type '(function (sys:int32 fixnum) sys:int32) iter))
(declare (inline iter))
(sys:int32-to-integer
(sys:int32-1+
(iter
(iter
(iter
(iter
(iter (sys:int32-1- nn) -1)
-2)
-4)
-8)
-16)))
)))
CL-USER 31 > (disassemble #'ceiling-pwr2)
200D8262:
0: 55 push ebp
1: 89E5 move ebp, esp
3: C1F802 sar eax, 2
6: 83E801 sub eax, 1
9: 89C7 move edi, eax
11: C1FFFF sar edi, FF
14: 0BC7 or eax, edi
16: 89C7 move edi, eax
18: C1FFFE sar edi, FE
21: 0BC7 or eax, edi
23: 89C7 move edi, eax
25: C1FFFC sar edi, FC
28: 0BC7 or eax, edi
30: 89C7 move edi, eax
32: C1FFF8 sar edi, F8
35: 0BC7 or eax, edi
37: 89C7 move edi, eax
39: C1FFF0 sar edi, F0
42: 0BC7 or eax, edi
44: 83C001 add eax, 1
47: B501 moveb ch, 1
49: C9 leave
50: FF254CD71E20 jmp [201ED74C] ; SYSTEM::CHECK-IN-MAKE-BIGNUM
56: 90 nop
57: 90 nop
Dr. David McClain
Chief Technical Officer
Refined Audiometrics Laboratory
4391 N. Camino Ferreo
Tucson, AZ 85750
email: dbm@refined-audiometrics.com
phone: 1.520.390.3995