bignums and native back end

Henry Cejtin henry@sourcelight.com
Tue, 7 Nov 2000 16:42:49 -0600


The  optimizations  that  are  important,  which  with  the C back end happen
because the C compiler sees the #define's expanded, are:

    If you are comparing (i.e., polymorphic  equality)  an  IntInf.int  to  a
        constant  IntInf.int, and the constant is small enough to be a fixnum
        (i.e., in the range [-2^31, 2^31)), then the comparison  should  just
        be a direct 32-bit compare.

    If  you are doing arithmetic and you use the IntInf_areSmall(x, y) macro,
        if both x and y are small constants then the answer is  true.   If  x
        (or  y)  is a small constant, then don't bother with the bitwise and,
        just test y (or x) for being small.

The other thing that is useful (but  probably  not  as  important)  is  doing
compile-time  arithmetic  and  constant  folding.   Note,  you can do fancier
things than you could correctly  do  with  Int32's  because  overflows  can't
happen.  E.g.,
    x + c1 + c2
where c1 and c2 are constants (especially small ones) can be changed to
    x + (c1 + c2)
and now the constants can be added at compile time.

I'm  sure  that there are other tweaks that could be added, but the above two
are the most important.