bignums and native back end

Stephen Weeks MLton@sourcelight.com
Wed, 8 Nov 2000 16:13:01 -0800 (PST)


>    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.

This is already being done in cps/poly-equal.fun.

>    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.

I added both of these into the CPS shrinker.  In the process I wented ahead and
added all the other algebraic laws I could think of.

x * 1 = 1 * x = x
x * ~1 = ~1 * x = ~x
x * 0 = 0 * x = 0
x + 0 = 0 + x = x
x - 0 = x
0 - x = ~x
x > x = x < x = false
x >= x = x <= x = true
equal(x, x) = true