
GHC is not the spec, I am talking about GHC Haskell, not Haskell the
standard that I don't use.
On 32bit machines, GHC Int is 32bits. On 64bit GHC on 64bit machines Int is
64 bits.
If you have another well engineered suitable for wide use Haskell compiler
in mind, I'd love to try it out, but with interesting software you will be
using none portable features per target platform. And thats OK. Its a
tradeoff thats sometimes worth making.
On Jun 3, 2013 4:19 AM, "Tommy Thorn"
On Jun 3, 2013, at 00:23 , Carter Schonwald
wrote: Int is "native register sized integer"
Actually it's not. Read the definition. Int is only guaranteed to be 29 bits.
Here's *one* _actual_ data point (from a 2.8 GHz i7, 64-bit code):
time ./fib fib(43) = 701408733 3.27 real 3.27 user 0.00 sys time ./fib-safe fib(43) = 701408733 3.45 real 3.45 user 0.00 sys
(NB: I do not check the n-1 and n-2 as it's trivial to see from a data flow analysis that the proceeding conditional guarantees that those can't overflow. The empty asm() is necessary to get GCC to generate comparable code).
Obviously, for some examples this will be much worse, for others, much better, but without this implemented in GHC it will be difficult to measure.
Tommy