+20
−0
Loading
There's a VOP for `integer-length` for `(signed-byte 32)` arg, but not
one for `(unsigned-byte 32)`. We can use the `BSR` instruction to
handle this case.
Not sure exactly how to test this, but I did it manually by compiling
```
(defun zot-u (n)
(declare (type (unsigned-byte 32) n)
(optimize (speed 3)))
(integer-length n))
```
The disassembly is, in part
```
CL-USER> (disassemble 'zot-u)
604ad710: .entry zot-u(n) ; (function
...
70: L5: cmp edx, #x0 ; No-arg-parsing entry point
; [:non-local-entry]
73: je L6
75: bsr edx, edx
78: inc edx
79: shl edx, #x2
```
Without this VOP, the disassembly would be
```
228: L3: mov eax, dword ptr [#x609c31d4] ; #<FDEFINITION object for integer-length>
; No-arg-parsing entry point
; [:non-local-entry]
22e: mov ecx, #x4
233: push dword ptr [ebp-#x8]
;;; [9] (INTEGER-LENGTH N)
236: jmp dword ptr [eax+#x5] ; [:call-site]
```