[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yes, they are special, but...

                If the CASE statement you're talking about looks something like

                        (case <expression>
                          (0 ...)
                          (1 ...)
                          (t ...))

                then the 3600 compiler will compile this into a computed go (I believe
                this was introduced in Genera 7.1 or 7.2).  It does this when all the
                keys are non-negative integers and the key space isn't too sparse (more
                than half of the keys from 0 to the largest key are used).  

            Have you tried this on a machine with an IFU (including, I think, the G

    Exactly, and this is also why Ivory doesn't generally do dispatches.
    The basic issue is that a branch instruction makes information about the
    target PC available to earlier pipeline stages than a dispatch does.

There is a simple way to FORCE any lisp implementation to do a dispatch
for a case statement. This is to use array referencing and funcalling
and not any builtin dispatch instruction. This should be faster than
a series of conditional branches on any machine for a sufficiently
long series of branches. Just replace either

(case <expression>
 (0 ...)
 (1 ...)
 (2 ...)
 (t ...))


(let ((x <expression>))
 (cond ((= x 0) ...)
       ((= x 1) ...)
       ((= x 2) ...)
       (t ...)))


(let ((x <expression>))
 (if (> x <the number of cases>)
     (funcall (aref #(#'(lambda () ...)
                      #'(lambda () ...)
                      #'(lambda () ...)

I wonder if somebody replaced the dispatch in the inner loop in TeX
with this whether it would speed up and if so by how much. I would
do the experiment but I don't know how to rebuild TeX so could someone
else volunteer to do the experiment and let me know whet the results

    There's one possible performance hit, though, which is that the
    branch-and-test code favors the initial clauses, whereas a dispatch
    takes the same amount of time for each clause.  Ivory, and to a lesser
    extent IFU 3600s, can do quite a few branch-and-tests in the time it
    takes to do a dispatch.