#6135: Unboxed Booleans
---------------------------------+------------------------------------------
Reporter: benl | Owner: jstolarek
Type: feature request | Status: patch
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: #605 |
---------------------------------+------------------------------------------
Comment(by simonpj):
Good idea (giving new names to the new ops).
I've remembered why `Word#` is probably the right return type, not `Int#`:
because we want to perform logical operations like `and` and `or` on the
result of comparisons, and those work on `Word#` not `Int#`.
So to me that argues for the primops all returning `Int#`. Simon M what
do you say?
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6135#comment:42>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#6135: Unboxed Booleans
---------------------------------+------------------------------------------
Reporter: benl | Owner: jstolarek
Type: feature request | Status: patch
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: #605 |
---------------------------------+------------------------------------------
Comment(by jstolarek):
I just had this thought: how about we use the names of existing primops
for wrappers and give new names to modified primops, e.g.:
{{{
gtCharW# :: Char# -> Char# -> Word# -- Primop, new name
gtChar# :: Char# -> Char# -> Bool -- Wrapper, old name
}}}
This way the change will be backwards compatible.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6135#comment:40>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#6135: Unboxed Booleans
---------------------------------+------------------------------------------
Reporter: benl | Owner: jstolarek
Type: feature request | Status: patch
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: #605 |
---------------------------------+------------------------------------------
Comment(by simonmar):
Replying to [comment:31 benl]:
> there is really no reason to suggest that the result of a boolean
comparison operator might be negative! I suspect the reason tagToEnum#
currently takes an Int# is because literals like 5# are Int#.
There's no reason to suggest that the result of a boolean comparison might
be 3, yet `Word#` includes that value. I don't think `Int#` is any worse
than `Word#` in including lots of impossible values, and furthermore
there's a lot less friction to using `Int#` because everything else uses
it. Just saying.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6135#comment:37>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#6135: Unboxed Booleans
---------------------------------+------------------------------------------
Reporter: benl | Owner: jstolarek
Type: feature request | Status: patch
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: #605 |
---------------------------------+------------------------------------------
Comment(by simonpj):
I'd do it all on the same branch (eg on github.) and as part of one
ticket.
It should be easy to fix the 'deriving' code (in `TcGenDeriv`).
I don't care much about names, but I'd have thought:
{{{
gtChar# :: Char# -> Char# -> Word# -- Primop
gtCharB# :: Char# -> Char# -> Bool -- Wrapper
}}}
etc
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6135#comment:36>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#6135: Unboxed Booleans
---------------------------------+------------------------------------------
Reporter: benl | Owner: jstolarek
Type: feature request | Status: patch
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: #605 |
---------------------------------+------------------------------------------
Comment(by jstolarek):
After a moment of thinking: it will be much easier to first change the
types of dataToTag# and tagToEnum# to use Word# and then work on primops.
Should I create a separate ticket so that changes to dataToTag# and
tagToEnum# can be merged to HEAD before the work on new primops is
finished?
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6135#comment:35>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#6135: Unboxed Booleans
---------------------------------+------------------------------------------
Reporter: benl | Owner: jstolarek
Type: feature request | Status: patch
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: #605 |
---------------------------------+------------------------------------------
Comment(by jstolarek):
Wiki page is up to date and shows one example benchmark where the code is
about 3 times faster thanks to the new primops. I also have an idea for
one more benchmark, but I'm not yet sure whether it'll give good results.
Changing the type of dataToTag# and tagToEnum# to maintain consistency
sounds like a good idea. I can take care of that, once I'm done with
comparison primops.
At the moment I hit a rather serious problem (or so it seems) - changing
the return type of comparisons breaks automatic deriving of instances for
Ord and Eq. I'm yet to figure out how to fix that.
Right now I would insist to decide what names should the wrappers have.
There will be lots of changes needed and I would like to avoid going
through this twice. My proposals are:
{{{
gtCharBool#, geCharBool#, eqCharBool#,
neCharBool#, ltCharBool#, leCharBool#,
(>$#), (>=$#), (==$#), (/=$#), (<$#), (<=$#),
gtWordBool#, geWordBool#, eqWordBool#,
neWordBool#, ltWordBool#, leWordBool#,
(>$##), (>=$##), (==$##), (/=$##), (<$##), (<=$##),
gtFloatBool#, geFloatBool#, eqFloatBool#,
neFloatBool#, ltFloatBool#, leFloatBool#,
gtAddrBool#, geAddrBool#, eqAddrBool#,
neAddrBool#, ltAddrBool#, leAddrBool#
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6135#comment:34>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler