From: Paul K. <pv...@pv...> - 2013-11-12 18:53:16
|
Paul Khuong wrote: > Douglas Katzman wrote: >> Another thing. Despite forcing there to be no type-check on the 'index', >> we emit (IF blah NIL NIL), >> respectively (IF blah T T) by substituting -1 for 0. >> >> * (disassemble '(lambda (x) (logbitp (truly-the unsigned-byte x) 0))) [...] > That's because the IF node branches to two equivalent but different > basic blocks. It should be possible to detect simple cases (e.g., nodes > that only deliver the same REF to the same LVAR). The logic would be > necessary to try and be more clever when choosing templates for > predicates (VOPs that directly jump to a target vs only computing flags). I now see it's not immediately apparent that the branch comes from the transform for LOGBITP: (deftransform logbitp ((index integer) (unsigned-byte (or (signed-byte #.sb!vm:n-word-bits) (unsigned-byte #.sb!vm:n-word-bits)))) `(if (>= index #.sb!vm:n-word-bits) (minusp integer) (not (zerop (logand integer (ash 1 index)))))) It's a transform because inlining only happens when the second argument is a machine word (also, there's a slight [common] bug in the type specification for that argument). Now that I think about it though, these two cases should really be handled in the transform. LOGBITP of 0 and -1 are trivial cases of the kind of type-directed simplifications we do for bitwise ops and modular arithmetic. A general transform on LOGBITP seems more elegant to me. Paul Khuong |