| > I'm confused. GHC of course unboxes strict fields of primitive data types.
| >
| > {-# OPTIONS -O2 -fvia-C -optc-O2 -funbox-strict-fields #-}
|
| ... but only when you give -funbox-strict-fields, as there, or UNPACK.
| The point is that it never loses sharing to unbox a strict Int field
| [1], so it should do that with -O, even without either of the above
| overrides.
|
| [1] I'm not sure if this is true... if it has to rebox the Int, you get
| another copy floating around, not the original, right?
Correct. If you have
data T = MkT {-# UNPACK #-} !Int
then given
case x of { MkT y -> h y }
then GHC must re-box the 'y' before passing it to h. That's why unpacking
strict fields isn't an unambiguous win. Perhaps it should be the default,
though, which can be switched off, rather than the reverse.
Simon
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe