Bools are not unboxed
Simon Marlow
simonmar at microsoft.com
Tue Oct 5 08:48:30 EDT 2004
On 03 October 2004 14:07, Tomasz Zielonka wrote:
> Then I noticed the cause:
> GHC.Prim.<# returns a boxed, heap allocated Bool, and so do other
> primitive comparison operators.
>
> Would it be difficult to add Bool unboxing to GHC?
> Maybe it would suffice to use preallocated False and True?
Just to clarify a little more: although the raw primitive operations do
appear to return fully boxed True & False values, in practice they
rarely do, because the code genrator optimises
case a >=# b of
True -> e1
False -> e2
to
if (a >=# b) {
.. code for e1 ...
} else {
.. code for e2 ..
}
(well, more or less). Only if the result of the comparison is actually
being returned from a function does it get turned into a real Bool.
It would probably be better to return 0#/1# instead of a Bool from the
comparison primops, because this would expose slightly more detail to
the simplifier and might result in slightly better code in some cases
(but no dramatic improvements). It would also let us remove a bit of
complexity from the code generator.
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list