A while ago, I needed lots of fairly small positive numbers,
together with a small number of flags for each, so I thought
I'd switch from Int to Word, and map the flags to bits.

Since there are few guarantees about the size of a Word (or Int), surely
it would be better to choose a definitely sized basic type, e.g. Word8
or Word16?

Good point in principle, and I would indeed prefer a specific size.
Unfortunately, I found just the opposite of this

I vaguely recall that ghc used to generate better code for
definitely sized WordN than the generic unguaranteed-size Word.

to be true (although I don't recall whether I checked with IntN or
WordN, and I don't have a small example for this issue): Even
just replacing Int with Int32 on a system where that should be
the same was liable to reduce performance..

Given Don's point about SPECIALI[ZS]E, and the lack of
specialisations for IntN/WordN, that might explain it?

Claus

PS. perhaps on newer 64 bit machines, explicitly selecting
   32 bits can offer savings? I'd certainly expect selecting
   64 bits on a 32 bit machine to lead to slowdowns.

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to